OleDbDataReader.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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. //
  12. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining
  15. // a copy of this software and associated documentation files (the
  16. // "Software"), to deal in the Software without restriction, including
  17. // without limitation the rights to use, copy, modify, merge, publish,
  18. // distribute, sublicense, and/or sell copies of the Software, and to
  19. // permit persons to whom the Software is furnished to do so, subject to
  20. // the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be
  23. // included in all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  29. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  30. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  31. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. //
  33. using System.Collections;
  34. using System.ComponentModel;
  35. using System.Data;
  36. using System.Data.Common;
  37. using System.Runtime.InteropServices;
  38. namespace System.Data.OleDb
  39. {
  40. public sealed class OleDbDataReader : MarshalByRefObject, IDataReader, IDisposable, IDataRecord, IEnumerable
  41. {
  42. #region Fields
  43. private OleDbCommand command;
  44. private bool open;
  45. private ArrayList gdaResults;
  46. private int currentResult;
  47. private int currentRow;
  48. private bool disposed = false;
  49. #endregion
  50. #region Constructors
  51. internal OleDbDataReader (OleDbCommand command, ArrayList results)
  52. {
  53. this.command = command;
  54. open = true;
  55. if (results != null)
  56. gdaResults = results;
  57. else
  58. gdaResults = new ArrayList ();
  59. currentResult = -1;
  60. currentRow = -1;
  61. }
  62. #endregion
  63. #region Properties
  64. public int Depth {
  65. get {
  66. return 0; // no nested selects supported
  67. }
  68. }
  69. public int FieldCount {
  70. get {
  71. if (currentResult < 0 ||
  72. currentResult >= gdaResults.Count)
  73. return 0;
  74. return libgda.gda_data_model_get_n_columns (
  75. (IntPtr) gdaResults[currentResult]);
  76. }
  77. }
  78. public bool IsClosed {
  79. get {
  80. return !open;
  81. }
  82. }
  83. public object this[string name] {
  84. get {
  85. int pos;
  86. if (currentResult == -1)
  87. throw new InvalidOperationException ();
  88. pos = libgda.gda_data_model_get_column_position (
  89. (IntPtr) gdaResults[currentResult],
  90. name);
  91. if (pos == -1)
  92. throw new IndexOutOfRangeException ();
  93. return this[pos];
  94. }
  95. }
  96. public object this[int index] {
  97. get {
  98. return (object) GetValue (index);
  99. }
  100. }
  101. public int RecordsAffected {
  102. get {
  103. int total_rows;
  104. if (currentResult < 0 ||
  105. currentResult >= gdaResults.Count)
  106. return 0;
  107. total_rows = libgda.gda_data_model_get_n_rows (
  108. (IntPtr) gdaResults[currentResult]);
  109. if (total_rows > 0) {
  110. if (FieldCount > 0) {
  111. // It's a SELECT statement
  112. return -1;
  113. }
  114. }
  115. return FieldCount > 0 ? -1 : total_rows;
  116. }
  117. }
  118. [MonoTODO]
  119. public bool HasRows {
  120. get {
  121. throw new NotImplementedException ();
  122. }
  123. }
  124. #endregion
  125. #region Methods
  126. public void Close ()
  127. {
  128. for (int i = 0; i < gdaResults.Count; i++) {
  129. IntPtr obj = (IntPtr) gdaResults[i];
  130. libgda.FreeObject (obj);
  131. }
  132. gdaResults.Clear ();
  133. gdaResults = null;
  134. open = false;
  135. currentResult = -1;
  136. currentRow = -1;
  137. }
  138. public bool GetBoolean (int ordinal)
  139. {
  140. IntPtr value;
  141. if (currentResult == -1)
  142. throw new InvalidCastException ();
  143. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  144. ordinal, currentRow);
  145. if (value == IntPtr.Zero)
  146. throw new InvalidCastException ();
  147. if (libgda.gda_value_get_type (value) != GdaValueType.Boolean)
  148. throw new InvalidCastException ();
  149. return libgda.gda_value_get_boolean (value);
  150. }
  151. public byte GetByte (int ordinal)
  152. {
  153. IntPtr value;
  154. if (currentResult == -1)
  155. throw new InvalidCastException ();
  156. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  157. ordinal, currentRow);
  158. if (value == IntPtr.Zero)
  159. throw new InvalidCastException ();
  160. if (libgda.gda_value_get_type (value) != GdaValueType.Tinyint)
  161. throw new InvalidCastException ();
  162. return libgda.gda_value_get_tinyint (value);
  163. }
  164. [MonoTODO]
  165. public long GetBytes (int ordinal, long dataIndex, byte[] buffer, int bufferIndex, int length)
  166. {
  167. throw new NotImplementedException ();
  168. }
  169. [EditorBrowsableAttribute (EditorBrowsableState.Never)]
  170. public char GetChar (int ordinal)
  171. {
  172. IntPtr value;
  173. if (currentResult == -1)
  174. throw new InvalidCastException ();
  175. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  176. ordinal, currentRow);
  177. if (value == IntPtr.Zero)
  178. throw new InvalidCastException ();
  179. if (libgda.gda_value_get_type (value) != GdaValueType.Tinyint)
  180. throw new InvalidCastException ();
  181. return (char) libgda.gda_value_get_tinyint (value);
  182. }
  183. [MonoTODO]
  184. public long GetChars (int ordinal, long dataIndex, char[] buffer, int bufferIndex, int length)
  185. {
  186. throw new NotImplementedException ();
  187. }
  188. [MonoTODO]
  189. public OleDbDataReader GetData (int ordinal)
  190. {
  191. throw new NotImplementedException ();
  192. }
  193. public string GetDataTypeName (int index)
  194. {
  195. IntPtr attrs;
  196. GdaValueType type;
  197. if (currentResult == -1)
  198. return "unknown";
  199. attrs = libgda.gda_data_model_describe_column ((IntPtr) gdaResults[currentResult],
  200. index);
  201. if (attrs == IntPtr.Zero)
  202. return "unknown";
  203. type = libgda.gda_field_attributes_get_gdatype (attrs);
  204. libgda.gda_field_attributes_free (attrs);
  205. return libgda.gda_type_to_string (type);
  206. }
  207. public DateTime GetDateTime (int ordinal)
  208. {
  209. IntPtr value;
  210. DateTime dt;
  211. if (currentResult == -1)
  212. throw new InvalidCastException ();
  213. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  214. ordinal, currentRow);
  215. if (value == IntPtr.Zero)
  216. throw new InvalidCastException ();
  217. if (libgda.gda_value_get_type (value) == GdaValueType.Date) {
  218. GdaDate gdt;
  219. gdt = (GdaDate) Marshal.PtrToStructure (libgda.gda_value_get_date (value),
  220. typeof (GdaDate));
  221. return new DateTime ((int) gdt.year, (int) gdt.month, (int) gdt.day);
  222. } else if (libgda.gda_value_get_type (value) == GdaValueType.Time) {
  223. GdaTime gdt;
  224. gdt = (GdaTime) Marshal.PtrToStructure (libgda.gda_value_get_time (value),
  225. typeof (GdaTime));
  226. return new DateTime (0, 0, 0, (int) gdt.hour, (int) gdt.minute, (int) gdt.second, 0);
  227. } else if (libgda.gda_value_get_type (value) == GdaValueType.Timestamp) {
  228. GdaTimestamp gdt;
  229. gdt = (GdaTimestamp) Marshal.PtrToStructure (libgda.gda_value_get_timestamp (value),
  230. typeof (GdaTimestamp));
  231. return new DateTime ((int) gdt.year, (int) gdt.month, (int) gdt.day,
  232. (int) gdt.hour, (int) gdt.minute, (int) gdt.second,
  233. (int) gdt.fraction);
  234. }
  235. throw new InvalidCastException ();
  236. }
  237. [MonoTODO]
  238. public decimal GetDecimal (int ordinal)
  239. {
  240. throw new NotImplementedException ();
  241. }
  242. public double GetDouble (int ordinal)
  243. {
  244. IntPtr value;
  245. if (currentResult == -1)
  246. throw new InvalidCastException ();
  247. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  248. ordinal, currentRow);
  249. if (value == IntPtr.Zero)
  250. throw new InvalidCastException ();
  251. if (libgda.gda_value_get_type (value) != GdaValueType.Double)
  252. throw new InvalidCastException ();
  253. return libgda.gda_value_get_double (value);
  254. }
  255. [MonoTODO]
  256. public Type GetFieldType (int index)
  257. {
  258. IntPtr value;
  259. GdaValueType type;
  260. if (currentResult == -1)
  261. throw new IndexOutOfRangeException ();
  262. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  263. index, currentRow);
  264. if (value == IntPtr.Zero)
  265. throw new IndexOutOfRangeException ();
  266. type = libgda.gda_value_get_type (value);
  267. switch (type) {
  268. case GdaValueType.Bigint : return typeof (long);
  269. case GdaValueType.Boolean : return typeof (bool);
  270. case GdaValueType.Date : return typeof (DateTime);
  271. case GdaValueType.Double : return typeof (double);
  272. case GdaValueType.Integer : return typeof (int);
  273. case GdaValueType.Single : return typeof (float);
  274. case GdaValueType.Smallint : return typeof (byte);
  275. case GdaValueType.String : return typeof (string);
  276. case GdaValueType.Time : return typeof (DateTime);
  277. case GdaValueType.Timestamp : return typeof (DateTime);
  278. case GdaValueType.Tinyint : return typeof (byte);
  279. }
  280. return typeof(string); // default
  281. }
  282. public float GetFloat (int ordinal)
  283. {
  284. IntPtr value;
  285. if (currentResult == -1)
  286. throw new InvalidCastException ();
  287. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  288. ordinal, currentRow);
  289. if (value == IntPtr.Zero)
  290. throw new InvalidCastException ();
  291. if (libgda.gda_value_get_type (value) != GdaValueType.Single)
  292. throw new InvalidCastException ();
  293. return libgda.gda_value_get_single (value);
  294. }
  295. [MonoTODO]
  296. public Guid GetGuid (int ordinal)
  297. {
  298. throw new NotImplementedException ();
  299. }
  300. public short GetInt16 (int ordinal)
  301. {
  302. IntPtr value;
  303. if (currentResult == -1)
  304. throw new InvalidCastException ();
  305. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  306. ordinal, currentRow);
  307. if (value == IntPtr.Zero)
  308. throw new InvalidCastException ();
  309. if (libgda.gda_value_get_type (value) != GdaValueType.Smallint)
  310. throw new InvalidCastException ();
  311. return (short) libgda.gda_value_get_smallint (value);
  312. }
  313. public int GetInt32 (int ordinal)
  314. {
  315. IntPtr value;
  316. if (currentResult == -1)
  317. throw new InvalidCastException ();
  318. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  319. ordinal, currentRow);
  320. if (value == IntPtr.Zero)
  321. throw new InvalidCastException ();
  322. if (libgda.gda_value_get_type (value) != GdaValueType.Integer)
  323. throw new InvalidCastException ();
  324. return libgda.gda_value_get_integer (value);
  325. }
  326. public long GetInt64 (int ordinal)
  327. {
  328. IntPtr value;
  329. if (currentResult == -1)
  330. throw new InvalidCastException ();
  331. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  332. ordinal, currentRow);
  333. if (value == IntPtr.Zero)
  334. throw new InvalidCastException ();
  335. if (libgda.gda_value_get_type (value) != GdaValueType.Bigint)
  336. throw new InvalidCastException ();
  337. return libgda.gda_value_get_bigint (value);
  338. }
  339. public string GetName (int index)
  340. {
  341. if (currentResult == -1)
  342. return null;
  343. return libgda.gda_data_model_get_column_title (
  344. (IntPtr) gdaResults[currentResult], index);
  345. }
  346. public int GetOrdinal (string name)
  347. {
  348. if (currentResult == -1)
  349. throw new IndexOutOfRangeException ();
  350. for (int i = 0; i < FieldCount; i++) {
  351. if (GetName (i) == name)
  352. return i;
  353. }
  354. throw new IndexOutOfRangeException ();
  355. }
  356. public DataTable GetSchemaTable ()
  357. {
  358. DataTable dataTableSchema = null;
  359. // Only Results from SQL SELECT Queries
  360. // get a DataTable for schema of the result
  361. // otherwise, DataTable is null reference
  362. if(this.FieldCount > 0) {
  363. IntPtr attrs;
  364. GdaValueType gdaType;
  365. long columnSize = 0;
  366. if (currentResult == -1) {
  367. // FIXME: throw an exception?
  368. #if DEBUG_OleDbDataReader
  369. Console.WriteLine("Error: current result -1");
  370. #endif
  371. return null;
  372. }
  373. dataTableSchema = new DataTable ();
  374. dataTableSchema.Columns.Add ("ColumnName", typeof (string));
  375. dataTableSchema.Columns.Add ("ColumnOrdinal", typeof (int));
  376. dataTableSchema.Columns.Add ("ColumnSize", typeof (int));
  377. dataTableSchema.Columns.Add ("NumericPrecision", typeof (int));
  378. dataTableSchema.Columns.Add ("NumericScale", typeof (int));
  379. dataTableSchema.Columns.Add ("IsUnique", typeof (bool));
  380. dataTableSchema.Columns.Add ("IsKey", typeof (bool));
  381. DataColumn dc = dataTableSchema.Columns["IsKey"];
  382. dc.AllowDBNull = true; // IsKey can have a DBNull
  383. dataTableSchema.Columns.Add ("BaseCatalogName", typeof (string));
  384. dataTableSchema.Columns.Add ("BaseColumnName", typeof (string));
  385. dataTableSchema.Columns.Add ("BaseSchemaName", typeof (string));
  386. dataTableSchema.Columns.Add ("BaseTableName", typeof (string));
  387. dataTableSchema.Columns.Add ("DataType", typeof(Type));
  388. dataTableSchema.Columns.Add ("AllowDBNull", typeof (bool));
  389. dataTableSchema.Columns.Add ("ProviderType", typeof (int));
  390. dataTableSchema.Columns.Add ("IsAliased", typeof (bool));
  391. dataTableSchema.Columns.Add ("IsExpression", typeof (bool));
  392. dataTableSchema.Columns.Add ("IsIdentity", typeof (bool));
  393. dataTableSchema.Columns.Add ("IsAutoIncrement", typeof (bool));
  394. dataTableSchema.Columns.Add ("IsRowVersion", typeof (bool));
  395. dataTableSchema.Columns.Add ("IsHidden", typeof (bool));
  396. dataTableSchema.Columns.Add ("IsLong", typeof (bool));
  397. dataTableSchema.Columns.Add ("IsReadOnly", typeof (bool));
  398. DataRow schemaRow;
  399. DbType dbType;
  400. Type typ;
  401. for (int i = 0; i < this.FieldCount; i += 1 ) {
  402. schemaRow = dataTableSchema.NewRow ();
  403. attrs = libgda.gda_data_model_describe_column ((IntPtr) gdaResults[currentResult],
  404. i);
  405. if (attrs == IntPtr.Zero){
  406. // FIXME: throw exception
  407. #if DEBUG_OleDbDataReader
  408. Console.WriteLine("Error: attrs null");
  409. #endif
  410. return null;
  411. }
  412. gdaType = libgda.gda_field_attributes_get_gdatype (attrs);
  413. columnSize = libgda.gda_field_attributes_get_defined_size (attrs);
  414. libgda.gda_field_attributes_free (attrs);
  415. schemaRow["ColumnName"] = this.GetName(i);
  416. schemaRow["ColumnOrdinal"] = i + 1;
  417. schemaRow["ColumnSize"] = (int) columnSize;
  418. schemaRow["NumericPrecision"] = 0;
  419. schemaRow["NumericScale"] = 0;
  420. // TODO: need to get KeyInfo
  421. //if((cmdBehavior & CommandBehavior.KeyInfo) == CommandBehavior.KeyInfo) {
  422. // bool IsUnique, IsKey;
  423. // GetKeyInfo(field[i].Name, out IsUnique, out IsKey);
  424. //}
  425. //else {
  426. schemaRow["IsUnique"] = false;
  427. schemaRow["IsKey"] = DBNull.Value;
  428. //}
  429. schemaRow["BaseCatalogName"] = "";
  430. schemaRow["BaseColumnName"] = this.GetName(i);
  431. schemaRow["BaseSchemaName"] = "";
  432. schemaRow["BaseTableName"] = "";
  433. schemaRow["DataType"] = this.GetFieldType(i);
  434. schemaRow["AllowDBNull"] = false;
  435. schemaRow["ProviderType"] = (int) gdaType;
  436. schemaRow["IsAliased"] = false;
  437. schemaRow["IsExpression"] = false;
  438. schemaRow["IsIdentity"] = false;
  439. schemaRow["IsAutoIncrement"] = false;
  440. schemaRow["IsRowVersion"] = false;
  441. schemaRow["IsHidden"] = false;
  442. schemaRow["IsLong"] = false;
  443. schemaRow["IsReadOnly"] = false;
  444. schemaRow.AcceptChanges();
  445. dataTableSchema.Rows.Add (schemaRow);
  446. }
  447. #if DEBUG_OleDbDataReader
  448. Console.WriteLine("********** DEBUG Table Schema BEGIN ************");
  449. foreach (DataRow myRow in dataTableSchema.Rows) {
  450. foreach (DataColumn myCol in dataTableSchema.Columns)
  451. Console.WriteLine(myCol.ColumnName + " = " + myRow[myCol]);
  452. Console.WriteLine();
  453. }
  454. Console.WriteLine("********** DEBUG Table Schema END ************");
  455. #endif // DEBUG_OleDbDataReader
  456. }
  457. return dataTableSchema;
  458. }
  459. public string GetString (int ordinal)
  460. {
  461. IntPtr value;
  462. if (currentResult == -1)
  463. throw new InvalidCastException ();
  464. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  465. ordinal, currentRow);
  466. if (value == IntPtr.Zero)
  467. throw new InvalidCastException ();
  468. if (libgda.gda_value_get_type (value) != GdaValueType.String)
  469. throw new InvalidCastException ();
  470. return libgda.gda_value_get_string (value);
  471. }
  472. [MonoTODO]
  473. public TimeSpan GetTimeSpan (int ordinal)
  474. {
  475. throw new NotImplementedException ();
  476. }
  477. public object GetValue (int ordinal)
  478. {
  479. IntPtr value;
  480. GdaValueType type;
  481. if (currentResult == -1)
  482. throw new IndexOutOfRangeException ();
  483. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  484. ordinal, currentRow);
  485. if (value == IntPtr.Zero)
  486. throw new IndexOutOfRangeException ();
  487. type = libgda.gda_value_get_type (value);
  488. switch (type) {
  489. case GdaValueType.Bigint : return GetInt64 (ordinal);
  490. case GdaValueType.Boolean : return GetBoolean (ordinal);
  491. case GdaValueType.Date : return GetDateTime (ordinal);
  492. case GdaValueType.Double : return GetDouble (ordinal);
  493. case GdaValueType.Integer : return GetInt32 (ordinal);
  494. case GdaValueType.Single : return GetFloat (ordinal);
  495. case GdaValueType.Smallint : return GetByte (ordinal);
  496. case GdaValueType.String : return GetString (ordinal);
  497. case GdaValueType.Time : return GetDateTime (ordinal);
  498. case GdaValueType.Timestamp : return GetDateTime (ordinal);
  499. case GdaValueType.Tinyint : return GetByte (ordinal);
  500. }
  501. return (object) libgda.gda_value_stringify (value);
  502. }
  503. [MonoTODO]
  504. public int GetValues (object[] values)
  505. {
  506. throw new NotImplementedException ();
  507. }
  508. [MonoTODO]
  509. IDataReader IDataRecord.GetData (int ordinal)
  510. {
  511. throw new NotImplementedException ();
  512. }
  513. IEnumerator IEnumerable.GetEnumerator ()
  514. {
  515. return new DbEnumerator (this);
  516. }
  517. public bool IsDBNull (int ordinal)
  518. {
  519. IntPtr value;
  520. if (currentResult == -1)
  521. throw new IndexOutOfRangeException ();
  522. value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
  523. ordinal, currentRow);
  524. if (value == IntPtr.Zero)
  525. throw new IndexOutOfRangeException ();
  526. return libgda.gda_value_is_null (value);
  527. }
  528. public bool NextResult ()
  529. {
  530. int i = currentResult + 1;
  531. if (i >= 0 && i < gdaResults.Count) {
  532. currentResult++;
  533. return true;
  534. }
  535. return false;
  536. }
  537. public bool Read ()
  538. {
  539. if (currentResult < 0 ||
  540. currentResult >= gdaResults.Count)
  541. return false;
  542. currentRow++;
  543. if (currentRow <
  544. libgda.gda_data_model_get_n_rows ((IntPtr) gdaResults[currentResult]))
  545. return true;
  546. return false;
  547. }
  548. #endregion
  549. #region Destructors
  550. private void Dispose (bool disposing) {
  551. if (!this.disposed) {
  552. if (disposing) {
  553. // release any managed resources
  554. command = null;
  555. }
  556. // release any unmanaged resources
  557. if (gdaResults != null) {
  558. gdaResults.Clear ();
  559. gdaResults = null;
  560. }
  561. // close any handles
  562. if (open)
  563. Close ();
  564. this.disposed = true;
  565. }
  566. }
  567. void IDisposable.Dispose() {
  568. Dispose (true);
  569. }
  570. ~OleDbDataReader() {
  571. Dispose (false);
  572. }
  573. #endregion // Destructors
  574. }
  575. }