The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MySqlDataReader.xml 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <docs>
  2. <ClassSummary>
  3. <summary>
  4. Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited.
  5. </summary>
  6. <remarks>
  7. <para>
  8. To create a <B>MySQLDataReader</B>, you must call the <see cref="MySqlCommand.ExecuteReader()"/>
  9. method of the <see cref="MySqlCommand"/> object, rather than directly using a constructor.
  10. </para>
  11. <para>
  12. While the <B>MySqlDataReader</B> is in use, the associated <see cref="MySqlConnection"/>
  13. is busy serving the <B>MySqlDataReader</B>, and no other operations can be performed
  14. on the <B>MySqlConnection</B> other than closing it. This is the case until the
  15. <see cref="MySqlDataReader.Close"/> method of the <B>MySqlDataReader</B> is called.
  16. </para>
  17. <para>
  18. <see cref="MySqlDataReader.IsClosed"/> and <see cref="MySqlDataReader.RecordsAffected"/>
  19. are the only properties that you can call after the <B>MySqlDataReader</B> is
  20. closed. Though the <B>RecordsAffected</B> property may be accessed at any time
  21. while the <B>MySqlDataReader</B> exists, always call <B>Close</B> before returning
  22. the value of <B>RecordsAffected</B> to ensure an accurate return value.
  23. </para>
  24. <para>
  25. For optimal performance, <B>MySqlDataReader</B> avoids creating
  26. unnecessary objects or making unnecessary copies of data. As a result, multiple calls
  27. to methods such as <see cref="MySqlDataReader.GetValue"/> return a reference to the
  28. same object. Use caution if you are modifying the underlying value of the objects
  29. returned by methods such as <B>GetValue</B>.
  30. </para>
  31. </remarks>
  32. <example>
  33. The following example creates a <see cref="MySqlConnection"/>,
  34. a <see cref="MySqlCommand"/>, and a <B>MySqlDataReader</B>. The example reads through
  35. the data, writing it out to the console. Finally, the example closes the <B>MySqlDataReader</B>, then the
  36. <B>MySqlConnection</B>.
  37. <code lang="vbnet">
  38. Public Sub ReadMyData(myConnString As String)
  39. Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"
  40. Dim myConnection As New MySqlConnection(myConnString)
  41. Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
  42. myConnection.Open()
  43. Dim myReader As MySqlDataReader
  44. myReader = myCommand.ExecuteReader()
  45. ' Always call Read before accessing data.
  46. While myReader.Read()
  47. Console.WriteLine((myReader.GetInt32(0) &amp; ", " &amp; myReader.GetString(1)))
  48. End While
  49. ' always call Close when done reading.
  50. myReader.Close()
  51. ' Close the connection when done with it.
  52. myConnection.Close()
  53. End Sub 'ReadMyData
  54. </code>
  55. <code lang="C#">
  56. public void ReadMyData(string myConnString) {
  57. string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
  58. MySqlConnection myConnection = new MySqlConnection(myConnString);
  59. MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);
  60. myConnection.Open();
  61. MySqlDataReader myReader;
  62. myReader = myCommand.ExecuteReader();
  63. // Always call Read before accessing data.
  64. while (myReader.Read()) {
  65. Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
  66. }
  67. // always call Close when done reading.
  68. myReader.Close();
  69. // Close the connection when done with it.
  70. myConnection.Close();
  71. }
  72. </code>
  73. </example>
  74. </ClassSummary>
  75. <GetBytes>
  76. <remarks>
  77. <para>
  78. <B>GetBytes</B> returns the number of available bytes in the field. In most
  79. cases this is the exact length of the field. However, the number returned may be
  80. less than the true length of the field if <B>GetBytes</B> has already been used
  81. to obtain bytes from the field. This may be the case, for example, if the
  82. <see cref="MySqlDataReader"/> is reading a large data structure into a buffer.
  83. For more information, see the <B>SequentialAccess</B> setting for
  84. <see cref="MySqlCommand.CommandBehavior"/>.
  85. </para>
  86. <para>
  87. If you pass a buffer that is a null reference (<B>Nothing</B> in Visual
  88. Basic), <B>GetBytes</B> returns the length of the field in bytes.
  89. </para>
  90. <para>
  91. No conversions are performed; therefore the data retrieved must already be a
  92. byte array.
  93. </para>
  94. </remarks>
  95. </GetBytes>
  96. <GetTimeSpan>
  97. <overloads/>
  98. <summary>
  99. Gets the value of the specified column as a <see cref="TimeSpan"/> object.
  100. </summary>
  101. <remarks>
  102. <para>
  103. No conversions are performed; therefore, the data retrieved must already be a <b>Time</b> value.
  104. </para>
  105. <para>
  106. Call IsDBNull to check for null values before calling this method.
  107. </para>
  108. </remarks>
  109. <param name="column">The zero-based column ordinal or column name.</param>
  110. <returns>The value of the specified column.</returns>
  111. </GetTimeSpan>
  112. <GetDateTime>
  113. <summary>
  114. Gets the value of the specified column as a <see cref="DateTime"/> object.
  115. </summary>
  116. <remarks>
  117. <para>
  118. No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
  119. </para>
  120. <para>
  121. Call IsDBNull to check for null values before calling this method.
  122. </para>
  123. <note>
  124. <para>
  125. MySql allows date columns to contain the value '0000-00-00' and datetime
  126. columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain
  127. or represent these values. To read a datetime value from a column that might
  128. contain zero values, use <see cref="GetMySqlDateTime(int)"/>.
  129. </para>
  130. <para>
  131. The behavior of reading a zero datetime column using this method is defined by the
  132. <i>ZeroDateTimeBehavior</i> connection string option. For more information on this option,
  133. please refer to <see cref="MySqlConnection.ConnectionString"/>.
  134. </para>
  135. </note>
  136. </remarks>
  137. <param name="i">The zero-based column ordinal.</param>
  138. <returns>The value of the specified column.</returns>
  139. </GetDateTime>
  140. <GetDateTimeS>
  141. <summary>
  142. Gets the value of the specified column as a <see cref="DateTime"/> object.
  143. </summary>
  144. <remarks>
  145. <para>
  146. No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
  147. </para>
  148. <para>
  149. Call IsDBNull to check for null values before calling this method.
  150. </para>
  151. <note>
  152. <para>
  153. MySql allows date columns to contain the value '0000-00-00' and datetime
  154. columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain
  155. or represent these values. To read a datetime value from a column that might
  156. contain zero values, use <see cref="GetMySqlDateTime(int)"/>.
  157. </para>
  158. <para>
  159. The behavior of reading a zero datetime column using this method is defined by the
  160. <i>ZeroDateTimeBehavior</i> connection string option. For more information on this option,
  161. please refer to <see cref="MySqlConnection.ConnectionString"/>.
  162. </para>
  163. </note>
  164. </remarks>
  165. <param name="column">The column name.</param>
  166. <returns>The value of the specified column.</returns>
  167. </GetDateTimeS>
  168. <GetMySqlDateTime>
  169. <summary>
  170. Gets the value of the specified column as a <see cref="MySql.Data.Types.MySqlDateTime"/> object.
  171. </summary>
  172. <remarks>
  173. <para>
  174. No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
  175. </para>
  176. <para>
  177. Call IsDBNull to check for null values before calling this method.
  178. </para>
  179. </remarks>
  180. <param name="column">The zero-based column ordinal or column name.</param>
  181. <returns>The value of the specified column.</returns>
  182. </GetMySqlDateTime>
  183. <GetString>
  184. <summary>
  185. Gets the value of the specified column as a <see cref="String"/> object.
  186. </summary>
  187. <remarks>
  188. <para>
  189. No conversions are performed; therefore, the data retrieved must already be a <b>String</b> object.
  190. </para>
  191. <para>
  192. Call IsDBNull to check for null values before calling this method.
  193. </para>
  194. </remarks>
  195. <param name="i">The zero-based column ordinal.</param>
  196. <returns>The value of the specified column.</returns>
  197. </GetString>
  198. <GetStringS>
  199. <summary>
  200. Gets the value of the specified column as a <see cref="String"/> object.
  201. </summary>
  202. <remarks>
  203. <para>
  204. No conversions are performed; therefore, the data retrieved must already be a <b>String</b> object.
  205. </para>
  206. <para>
  207. Call IsDBNull to check for null values before calling this method.
  208. </para>
  209. </remarks>
  210. <param name="column">The column name.</param>
  211. <returns>The value of the specified column.</returns>
  212. </GetStringS>
  213. <GetDecimal>
  214. <summary>
  215. Gets the value of the specified column as a <see cref="Decimal"/> object.
  216. </summary>
  217. <remarks>
  218. <para>
  219. No conversions are performed; therefore, the data retrieved must already be a <b>Decimal</b> object.
  220. </para>
  221. <para>
  222. Call IsDBNull to check for null values before calling this method.
  223. </para>
  224. </remarks>
  225. <param name="i">The zero-based column ordinal</param>
  226. <returns>The value of the specified column.</returns>
  227. </GetDecimal>
  228. <GetDecimalS>
  229. <summary>
  230. Gets the value of the specified column as a <see cref="Decimal"/> object.
  231. </summary>
  232. <remarks>
  233. <para>
  234. No conversions are performed; therefore, the data retrieved must already be a <b>Decimal</b> object.
  235. </para>
  236. <para>
  237. Call IsDBNull to check for null values before calling this method.
  238. </para>
  239. </remarks>
  240. <param name="column">The column name</param>
  241. <returns>The value of the specified column.</returns>
  242. </GetDecimalS>
  243. <GetDouble>
  244. <summary>Gets the value of the specified column as a double-precision floating point number.</summary>
  245. <remarks>
  246. <para>
  247. No conversions are performed; therefore, the data retrieved must already be a <b>Double</b> object.
  248. </para>
  249. <para>
  250. Call IsDBNull to check for null values before calling this method.
  251. </para>
  252. </remarks>
  253. <param name="i">The zero-based column ordinal.</param>
  254. <returns>The value of the specified column.</returns>
  255. </GetDouble>
  256. <GetDoubleS>
  257. <summary>Gets the value of the specified column as a double-precision floating point number.</summary>
  258. <remarks>
  259. <para>
  260. No conversions are performed; therefore, the data retrieved must already be a <b>Double</b> object.
  261. </para>
  262. <para>
  263. Call IsDBNull to check for null values before calling this method.
  264. </para>
  265. </remarks>
  266. <param name="column">The column name</param>
  267. <returns>The value of the specified column.</returns>
  268. </GetDoubleS>
  269. <GetFloat>
  270. <summary>
  271. Gets the value of the specified column as a single-precision floating point number.
  272. </summary>
  273. <remarks>
  274. <para>
  275. No conversions are performed; therefore, the data retrieved must already be a <b>Float</b> object.
  276. </para>
  277. <para>
  278. Call IsDBNull to check for null values before calling this method.
  279. </para>
  280. </remarks>
  281. <param name="i">The zero-based column ordinal.</param>
  282. <returns>The value of the specified column.</returns>
  283. </GetFloat>
  284. <GetFloatS>
  285. <summary>
  286. Gets the value of the specified column as a single-precision floating point number.
  287. </summary>
  288. <remarks>
  289. <para>
  290. No conversions are performed; therefore, the data retrieved must already be a <b>Float</b> object.
  291. </para>
  292. <para>
  293. Call IsDBNull to check for null values before calling this method.
  294. </para>
  295. </remarks>
  296. <param name="column">The column name</param>
  297. <returns>The value of the specified column.</returns>
  298. </GetFloatS>
  299. <GetGiud>
  300. <summary>Gets the value of the specified column as a globally-unique identifier (GUID).</summary>
  301. <param name="i">The zero-based column ordinal.</param>
  302. <returns>The value of the specified column.</returns>
  303. </GetGiud>
  304. <GetGiudS>
  305. <summary>Gets the value of the specified column as a globally-unique identifier (GUID).</summary>
  306. <param name="column">The column name</param>
  307. <returns>The value of the specified column.</returns>
  308. </GetGiudS>
  309. <GetInt16>
  310. <summary>Gets the value of the specified column as a 16-bit signed integer.</summary>
  311. <remarks>
  312. <para>
  313. No conversions are performed; therefore, the data retrieved must already be a <b>16 bit integer</b> value.
  314. </para>
  315. <para>
  316. Call IsDBNull to check for null values before calling this method.
  317. </para>
  318. </remarks>
  319. <param name="i">The zero-based column ordinal.</param>
  320. <returns>The value of the specified column.</returns>
  321. </GetInt16>
  322. <GetInt16S>
  323. <summary>Gets the value of the specified column as a 16-bit signed integer.</summary>
  324. <remarks>
  325. <para>
  326. No conversions are performed; threfore, the data retrieved must already be a <b>16 bit integer</b> value.
  327. </para>
  328. <para>
  329. Call IsDBNull to check for null values before calling this method.
  330. </para>
  331. </remarks>
  332. <param name="column">The column name</param>
  333. <returns>The value of the specified column.</returns>
  334. </GetInt16S>
  335. <GetInt32>
  336. <summary>Gets the value of the specified column as a 32-bit signed integer.</summary>
  337. <remarks>
  338. <para>
  339. No conversions are performed; therefore, the data retrieved must already be a <b>32 bit integer</b> value.
  340. </para>
  341. <para>
  342. Call IsDBNull to check for null values before calling this method.
  343. </para>
  344. </remarks>
  345. <param name="i">The zero-based column ordinal.</param>
  346. <returns>The value of the specified column.</returns>
  347. </GetInt32>
  348. <GetInt32S>
  349. <summary>Gets the value of the specified column as a 32-bit signed integer.</summary>
  350. <remarks>
  351. <para>
  352. No conversions are performed; therefore, the data retrieved must already be a <b>32 bit integer</b> value.
  353. </para>
  354. <para>
  355. Call IsDBNull to check for null values before calling this method.
  356. </para>
  357. </remarks>
  358. <param name="column">The column name.</param>
  359. <returns>The value of the specified column.</returns>
  360. </GetInt32S>
  361. <GetInt64>
  362. <summary>Gets the value of the specified column as a 64-bit signed integer.</summary>
  363. <remarks>
  364. <para>
  365. No conversions are performed; therefore, the data retrieved must already be a <b>64 bit integer</b> value.
  366. </para>
  367. <para>
  368. Call IsDBNull to check for null values before calling this method.
  369. </para>
  370. </remarks>
  371. <param name="i">The zero-based column ordinal.</param>
  372. <returns>The value of the specified column.</returns>
  373. </GetInt64>
  374. <GetInt64S>
  375. <summary>Gets the value of the specified column as a 64-bit signed integer.</summary>
  376. <remarks>
  377. <para>
  378. No conversions are performed; therefore, the data retrieved must already be a <b>64 bit integer</b> value.
  379. </para>
  380. <para>
  381. Call IsDBNull to check for null values before calling this method.
  382. </para>
  383. </remarks>
  384. <param name="column">The column name.</param>
  385. <returns>The value of the specified column.</returns>
  386. </GetInt64S>
  387. <GetUInt16>
  388. <summary>Gets the value of the specified column as a 16-bit unsigned integer.</summary>
  389. <remarks>
  390. <para>
  391. No conversions are performed; therefore, the data retrieved must already be a <b>16 bit unsigned integer</b> value.
  392. </para>
  393. <para>
  394. Call IsDBNull to check for null values before calling this method.
  395. </para>
  396. </remarks>
  397. <param name="column">The zero-based column ordinal or column name.</param>
  398. <returns>The value of the specified column.</returns>
  399. </GetUInt16>
  400. <GetUInt32>
  401. <summary>Gets the value of the specified column as a 32-bit unsigned integer.</summary>
  402. <remarks>
  403. <para>
  404. No conversions are performed; therefore, the data retrieved must already be a <b>32 bit unsigned integer</b> value.
  405. </para>
  406. <para>
  407. Call IsDBNull to check for null values before calling this method.
  408. </para>
  409. </remarks>
  410. <param name="column">The zero-based column ordinal or column name.</param>
  411. <returns>The value of the specified column.</returns>
  412. </GetUInt32>
  413. <GetUInt64>
  414. <summary>Gets the value of the specified column as a 64-bit unsigned integer.</summary>
  415. <remarks>
  416. <para>
  417. No conversions are performed; therefore, the data retrieved must already be a <b>64 bit unsigned integer</b> value.
  418. </para>
  419. <para>
  420. Call IsDBNull to check for null values before calling this method.
  421. </para>
  422. </remarks>
  423. <param name="column">The zero-based column ordinal or column name.</param>
  424. <returns>The value of the specified column.</returns>
  425. </GetUInt64>
  426. </docs>