OleDbDataReader.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. //
  2. // System.Data.OleDb.OleDbDataReader
  3. //
  4. // Author:
  5. // Rodrigo Moya ([email protected])
  6. // Tim Coleman ([email protected])
  7. //
  8. // Copyright (C) Rodrigo Moya, 2002
  9. // Copyright (C) Tim Coleman, 2002
  10. //
  11. using System.Collections;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Data.Common;
  15. namespace System.Data.OleDb
  16. {
  17. public sealed class OleDbDataReader : MarshalByRefObject, IDataReader, IDisposable, IDataRecord, IEnumerable
  18. {
  19. #region Fields
  20. private OleDbCommand command;
  21. private bool open;
  22. private ArrayList gdaResults;
  23. private int currentResult;
  24. private int currentRow;
  25. private bool isOpened;
  26. #endregion
  27. #region Constructors
  28. internal OleDbDataReader (OleDbCommand command, ArrayList results)
  29. {
  30. this.command = command;
  31. open = true;
  32. if (results != null)
  33. gdaResults = results;
  34. else
  35. gdaResults = new ArrayList ();
  36. currentResult = -1;
  37. currentRow = -1;
  38. isOpened = true;
  39. }
  40. #endregion
  41. #region Properties
  42. public int Depth {
  43. [MonoTODO]
  44. get {
  45. throw new NotImplementedException ();
  46. }
  47. }
  48. public int FieldCount {
  49. get {
  50. if (currentResult < 0 ||
  51. currentResult >= gdaResults.Count)
  52. return 0;
  53. return libgda.gda_data_model_get_n_columns (
  54. (IntPtr) gdaResults[currentResult]);
  55. }
  56. }
  57. public bool IsClosed {
  58. get {
  59. return !isOpened;
  60. }
  61. }
  62. public object this[string name] {
  63. [MonoTODO]
  64. get { throw new NotImplementedException (); }
  65. }
  66. public object this[int index] {
  67. get {
  68. if (currentResult < 0 ||
  69. currentResult >= gdaResults.Count)
  70. return null;
  71. return libgda.gda_data_model_get_value_at (
  72. (IntPtr) gdaResults[currentResult],
  73. index,
  74. currentRow);
  75. }
  76. }
  77. public int RecordsAffected {
  78. get {
  79. int total_rows;
  80. if (currentResult < 0 ||
  81. currentResult >= gdaResults.Count)
  82. return 0;
  83. total_rows = libgda.gda_data_model_get_n_rows (
  84. (IntPtr) gdaResults[currentResult]);
  85. if (total_rows > 0) {
  86. if (FieldCount > 0) {
  87. // It's a SELECT statement
  88. return -1;
  89. }
  90. }
  91. return FieldCount > 0 ? -1 : total_rows;
  92. }
  93. }
  94. #endregion
  95. #region Methods
  96. [MonoTODO]
  97. public void Close ()
  98. {
  99. throw new NotImplementedException ();
  100. }
  101. [MonoTODO]
  102. ~OleDbDataReader ()
  103. {
  104. throw new NotImplementedException ();
  105. }
  106. public bool GetBoolean (int ordinal)
  107. {
  108. IntPtr value;
  109. if (currentResult == -1)
  110. return false;
  111. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  112. ordinal, currentRow);
  113. if (value != IntPtr.Zero) {
  114. if (libgda.gda_value_get_vtype (value) != GdaValueType.Boolean)
  115. throw new InvalidCastException ();
  116. return libgda.gda_value_get_boolean (value);
  117. }
  118. return false;
  119. }
  120. [MonoTODO]
  121. public byte GetByte (int ordinal)
  122. {
  123. throw new NotImplementedException ();
  124. }
  125. [MonoTODO]
  126. public long GetBytes (int ordinal, long dataIndex, byte[] buffer, int bufferIndex, int length)
  127. {
  128. throw new NotImplementedException ();
  129. }
  130. [MonoTODO]
  131. public char GetChar (int ordinal)
  132. {
  133. throw new NotImplementedException ();
  134. }
  135. [MonoTODO]
  136. public long GetChars (int ordinal, long dataIndex, char[] buffer, int bufferIndex, int length)
  137. {
  138. throw new NotImplementedException ();
  139. }
  140. [MonoTODO]
  141. public OleDbDataReader GetData (int ordinal)
  142. {
  143. throw new NotImplementedException ();
  144. }
  145. [MonoTODO]
  146. public string GetDataTypeName (int index)
  147. {
  148. throw new NotImplementedException ();
  149. }
  150. [MonoTODO]
  151. public DateTime GetDateTime (int ordinal)
  152. {
  153. throw new NotImplementedException ();
  154. }
  155. [MonoTODO]
  156. public decimal GetDecimal (int ordinal)
  157. {
  158. throw new NotImplementedException ();
  159. }
  160. [MonoTODO]
  161. public double GetDouble (int ordinal)
  162. {
  163. throw new NotImplementedException ();
  164. }
  165. [MonoTODO]
  166. public Type GetFieldType (int index)
  167. {
  168. throw new NotImplementedException ();
  169. }
  170. [MonoTODO]
  171. public float GetFloat (int ordinal)
  172. {
  173. throw new NotImplementedException ();
  174. }
  175. [MonoTODO]
  176. public Guid GetGuid (int ordinal)
  177. {
  178. throw new NotImplementedException ();
  179. }
  180. [MonoTODO]
  181. public short GetInt16 (int ordinal)
  182. {
  183. throw new NotImplementedException ();
  184. }
  185. [MonoTODO]
  186. public int GetInt32 (int ordinal)
  187. {
  188. throw new NotImplementedException ();
  189. }
  190. [MonoTODO]
  191. public long GetInt64 (int ordinal)
  192. {
  193. throw new NotImplementedException ();
  194. }
  195. [MonoTODO]
  196. public string GetName (int index)
  197. {
  198. throw new NotImplementedException ();
  199. }
  200. [MonoTODO]
  201. public int GetOrdinal (string name)
  202. {
  203. throw new NotImplementedException ();
  204. }
  205. [MonoTODO]
  206. public DataTable GetSchemaTable ()
  207. {
  208. throw new NotImplementedException ();
  209. }
  210. [MonoTODO]
  211. public string GetString (int ordinal)
  212. {
  213. throw new NotImplementedException ();
  214. }
  215. [MonoTODO]
  216. public TimeSpan GetTimeSpan (int ordinal)
  217. {
  218. throw new NotImplementedException ();
  219. }
  220. [MonoTODO]
  221. public object GetValue (int ordinal)
  222. {
  223. throw new NotImplementedException ();
  224. }
  225. [MonoTODO]
  226. public int GetValues (object[] values)
  227. {
  228. throw new NotImplementedException ();
  229. }
  230. [MonoTODO]
  231. IDataReader IDataRecord.GetData (int ordinal)
  232. {
  233. throw new NotImplementedException ();
  234. }
  235. [MonoTODO]
  236. void IDisposable.Dispose ()
  237. {
  238. throw new NotImplementedException ();
  239. }
  240. [MonoTODO]
  241. IEnumerator IEnumerable.GetEnumerator ()
  242. {
  243. throw new NotImplementedException ();
  244. }
  245. [MonoTODO]
  246. public bool IsDBNull (int ordinal)
  247. {
  248. throw new NotImplementedException ();
  249. }
  250. public bool NextResult ()
  251. {
  252. int i = currentResult + 1;
  253. if (i >= 0 && i < gdaResults.Count) {
  254. currentResult++;
  255. return true;
  256. }
  257. return false;
  258. }
  259. public bool Read ()
  260. {
  261. throw new NotImplementedException ();
  262. }
  263. #endregion
  264. }
  265. }