OleDbDataReader.cs 19 KB

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