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.

MySqlConnection.xml 50KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  1. <docs>
  2. <DefaultCtor>
  3. <summary>
  4. Initializes a new instance of the <see cref="MySqlConnection"/> class.
  5. </summary>
  6. <remarks>
  7. When a new instance of <see cref="MySqlConnection"/> is created, the read/write
  8. properties are set to the following initial values unless they are specifically
  9. set using their associated keywords in the <see cref="ConnectionString"/> property.
  10. <para/>
  11. <list type="table">
  12. <listheader>
  13. <term>Properties</term>
  14. <term>Initial Value</term>
  15. </listheader>
  16. <item>
  17. <term>
  18. <see cref="ConnectionString"/>
  19. </term>
  20. <term>empty string ("")</term>
  21. </item>
  22. <item>
  23. <term>
  24. <see cref="ConnectionTimeout"/>
  25. </term>
  26. <term>15</term>
  27. </item>
  28. <item>
  29. <term>
  30. <see cref="Database"/>
  31. </term>
  32. <term>empty string ("")</term>
  33. </item>
  34. <item>
  35. <term>
  36. <see cref="DataSource"/>
  37. </term>
  38. <term>empty string ("")</term>
  39. </item>
  40. <item>
  41. <term>
  42. <see cref="ServerVersion"/>
  43. </term>
  44. <term>empty string ("")</term>
  45. </item>
  46. </list>
  47. <para/>
  48. You can change the value for these properties only by using the <B>ConnectionString</B> property.
  49. </remarks>
  50. <example>
  51. </example>
  52. <overloads>
  53. <summary>
  54. Initializes a new instance of the <see cref="MySqlConnection"/> class.
  55. </summary>
  56. </overloads>
  57. </DefaultCtor>
  58. <Ctor1>
  59. <summary>
  60. Initializes a new instance of the <see cref="MySqlConnection"/> class when given a string containing the connection string.
  61. </summary>
  62. <remarks>
  63. When a new instance of <see cref="MySqlConnection"/> is created, the read/write
  64. properties are set to the following initial values unless they are specifically
  65. set using their associated keywords in the <see cref="ConnectionString"/> property.
  66. <para/>
  67. <list type="table">
  68. <listheader>
  69. <term>Properties</term>
  70. <term>Initial Value</term>
  71. </listheader>
  72. <item>
  73. <term>
  74. <see cref="ConnectionString"/>
  75. </term>
  76. <term>empty string ("")</term>
  77. </item>
  78. <item>
  79. <term>
  80. <see cref="ConnectionTimeout"/>
  81. </term>
  82. <term>15</term>
  83. </item>
  84. <item>
  85. <term>
  86. <see cref="Database"/>
  87. </term>
  88. <term>empty string ("")</term>
  89. </item>
  90. <item>
  91. <term>
  92. <see cref="DataSource"/>
  93. </term>
  94. <term>empty string ("")</term>
  95. </item>
  96. <item>
  97. <term>
  98. <see cref="ServerVersion"/>
  99. </term>
  100. <term>empty string ("")</term>
  101. </item>
  102. </list>
  103. <para/>
  104. You can change the value for these properties only by using the <B>ConnectionString</B> property.
  105. </remarks>
  106. <example>
  107. </example>
  108. <param name="connectionString">The connection properties used to open the MySQL database. </param>
  109. </Ctor1>
  110. <Open>
  111. <summary>Opens a database connection with the property settings specified by the ConnectionString.</summary>
  112. <exception cref="InvalidOperationException">Cannot open a connection without specifying a data source or server.</exception>
  113. <exception cref="MySqlException">A connection-level error occurred while opening the connection.</exception>
  114. <remarks>
  115. <para>
  116. The <see cref="MySqlConnection"/> draws an open connection from the connection pool if one is available.
  117. Otherwise, it establishes a new connection to an instance of MySQL.
  118. </para>
  119. </remarks>
  120. <example>
  121. The following example creates a <see cref="MySqlConnection"/>, opens it,
  122. displays some of its properties, then closes the connection.
  123. <code lang="vbnet">
  124. Public Sub CreateMySqlConnection(myConnString As String)
  125. Dim myConnection As New MySqlConnection(myConnString)
  126. myConnection.Open()
  127. MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
  128. + ControlChars.Cr + "State: " + myConnection.State.ToString())
  129. myConnection.Close()
  130. End Sub
  131. </code>
  132. <code lang="C#">
  133. public void CreateMySqlConnection(string myConnString)
  134. {
  135. MySqlConnection myConnection = new MySqlConnection(myConnString);
  136. myConnection.Open();
  137. MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
  138. "\nState: " + myConnection.State.ToString());
  139. myConnection.Close();
  140. }
  141. </code>
  142. </example>
  143. </Open>
  144. <Database>
  145. <summary>Gets the name of the current database or the database to be used after a connection is opened.</summary>
  146. <returns>The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string.</returns>
  147. <remarks>
  148. <para>
  149. The <B>Database</B> property does not update dynamically.
  150. If you change the current database using a SQL statement, then this property
  151. may reflect the wrong value. If you change the current database using the <see cref="ChangeDatabase"/>
  152. method, this property is updated to reflect the new database.
  153. </para>
  154. </remarks>
  155. <example>
  156. The following example creates a <see cref="MySqlConnection"/> and displays
  157. some of its read-only properties.
  158. <code lang="vbnet">
  159. Public Sub CreateMySqlConnection()
  160. Dim myConnString As String = _
  161. "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"
  162. Dim myConnection As New MySqlConnection( myConnString )
  163. myConnection.Open()
  164. MessageBox.Show( "Server Version: " + myConnection.ServerVersion _
  165. + ControlChars.NewLine + "Database: " + myConnection.Database )
  166. myConnection.ChangeDatabase( "test2" )
  167. MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _
  168. + ControlChars.NewLine + "Database: " + myConnection.Database )
  169. myConnection.Close()
  170. End Sub
  171. </code>
  172. <code lang="C#">
  173. public void CreateMySqlConnection()
  174. {
  175. string myConnString =
  176. "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass";
  177. MySqlConnection myConnection = new MySqlConnection( myConnString );
  178. myConnection.Open();
  179. MessageBox.Show( "Server Version: " + myConnection.ServerVersion
  180. + "\nDatabase: " + myConnection.Database );
  181. myConnection.ChangeDatabase( "test2" );
  182. MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion
  183. + "\nDatabase: " + myConnection.Database );
  184. myConnection.Close();
  185. }
  186. </code>
  187. </example>
  188. </Database>
  189. <State>
  190. <summary>Gets the current state of the connection.</summary>
  191. <returns>
  192. A bitwise combination of the <see cref="System.Data.ConnectionState"/> values. The default is <B>Closed</B>.
  193. </returns>
  194. <remarks>
  195. The allowed state changes are:
  196. <list type="bullet">
  197. <item>
  198. From <B>Closed</B> to <B>Open</B>, using the <B>Open</B> method of the connection object.
  199. </item>
  200. <item>
  201. From <B>Open</B> to <B>Closed</B>, using either the <B>Close</B> method or the <B>Dispose</B> method of the connection object.
  202. </item>
  203. </list>
  204. </remarks>
  205. <example>
  206. The following example creates a <see cref="MySqlConnection"/>, opens it,
  207. displays some of its properties, then closes the connection.
  208. <code lang="vbnet">
  209. Public Sub CreateMySqlConnection(myConnString As String)
  210. Dim myConnection As New MySqlConnection(myConnString)
  211. myConnection.Open()
  212. MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
  213. + ControlChars.Cr + "State: " + myConnection.State.ToString())
  214. myConnection.Close()
  215. End Sub
  216. </code>
  217. <code lang="C#">
  218. public void CreateMySqlConnection(string myConnString)
  219. {
  220. MySqlConnection myConnection = new MySqlConnection(myConnString);
  221. myConnection.Open();
  222. MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
  223. "\nState: " + myConnection.State.ToString());
  224. myConnection.Close();
  225. }
  226. </code>
  227. </example>
  228. </State>
  229. <ServerVersion>
  230. <summary>Gets a string containing the version of the MySQL server to which the client is connected.</summary>
  231. <returns>The version of the instance of MySQL.</returns>
  232. <exception cref="InvalidOperationException">The connection is closed.</exception>
  233. <example>
  234. The following example creates a <see cref="MySqlConnection"/>, opens it,
  235. displays some of its properties, then closes the connection.
  236. <code lang="vbnet">
  237. Public Sub CreateMySqlConnection(myConnString As String)
  238. Dim myConnection As New MySqlConnection(myConnString)
  239. myConnection.Open()
  240. MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
  241. + ControlChars.Cr + "State: " + myConnection.State.ToString())
  242. myConnection.Close()
  243. End Sub
  244. </code>
  245. <code lang="C#">
  246. public void CreateMySqlConnection(string myConnString)
  247. {
  248. MySqlConnection myConnection = new MySqlConnection(myConnString);
  249. myConnection.Open();
  250. MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
  251. "\nState: " + myConnection.State.ToString());
  252. myConnection.Close();
  253. }
  254. </code>
  255. </example>
  256. </ServerVersion>
  257. <Close>
  258. <summary>Closes the connection to the database. This is the preferred method of closing any open connection.</summary>
  259. <remarks>
  260. <para>
  261. The <B>Close</B> method rolls back any pending transactions. It then releases
  262. the connection to the connection pool, or closes the connection if connection
  263. pooling is disabled.
  264. </para>
  265. <para>
  266. An application can call <B>Close</B> more than one time. No exception is
  267. generated.
  268. </para>
  269. </remarks>
  270. <example>
  271. The following example creates a <see cref="MySqlConnection"/>, opens it,
  272. displays some of its properties, then closes the connection.
  273. <code lang="vbnet">
  274. Public Sub CreateMySqlConnection(myConnString As String)
  275. Dim myConnection As New MySqlConnection(myConnString)
  276. myConnection.Open()
  277. MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
  278. + ControlChars.Cr + "State: " + myConnection.State.ToString())
  279. myConnection.Close()
  280. End Sub
  281. </code>
  282. <code lang="C#">
  283. public void CreateMySqlConnection(string myConnString)
  284. {
  285. MySqlConnection myConnection = new MySqlConnection(myConnString);
  286. myConnection.Open();
  287. MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
  288. "\nState: " + myConnection.State.ToString());
  289. myConnection.Close();
  290. }
  291. </code>
  292. </example>
  293. </Close>
  294. <CreateCommand>
  295. <summary>
  296. Creates and returns a <see cref="MySqlCommand"/> object associated with the <see cref="MySqlConnection"/>.
  297. </summary>
  298. <returns>
  299. A <see cref="MySqlCommand"/> object.
  300. </returns>
  301. </CreateCommand>
  302. <BeginTransaction>
  303. <summary>Begins a database transaction.</summary>
  304. <returns>An object representing the new transaction.</returns>
  305. <exception cref="InvalidOperationException">Parallel transactions are not supported.</exception>
  306. <remarks>
  307. <para>This command is equivalent to the MySQL BEGIN TRANSACTION command.</para>
  308. <para>
  309. You must explicitly commit or roll back the transaction using the <see cref="MySqlTransaction.Commit"/> or
  310. <see cref="MySqlTransaction.Rollback"/> method.
  311. <note>
  312. If you do not specify an isolation level, the default isolation level is used. To specify an isolation
  313. level with the <see cref="BeginTransaction()"/> method, use the overload that takes the <I>iso</I> parameter. Also
  314. note that any attempt to begin a transaction while a transaction is in progress will throw an exception on MySQL 4.1 and higher.
  315. On MySQL 4.0, an exception will not be thrown because servers 4.0 and earlier did not report their transacation status.
  316. </note>
  317. </para>
  318. </remarks>
  319. <example>
  320. The following example creates a <see cref="MySqlConnection"/> and a
  321. <see cref="MySqlTransaction"/>. It also demonstrates how to use the <B>BeginTransaction</B>, a
  322. <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.
  323. <code lang="vbnet">
  324. Public Sub RunTransaction(myConnString As String)
  325. Dim myConnection As New MySqlConnection(myConnString)
  326. myConnection.Open()
  327. Dim myCommand As MySqlCommand = myConnection.CreateCommand()
  328. Dim myTrans As MySqlTransaction
  329. ' Start a local transaction
  330. myTrans = myConnection.BeginTransaction()
  331. ' Must assign both transaction object and connection
  332. ' to Command object for a pending local transaction
  333. myCommand.Connection = myConnection
  334. myCommand.Transaction = myTrans
  335. Try
  336. myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')"
  337. myCommand.ExecuteNonQuery()
  338. myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')"
  339. myCommand.ExecuteNonQuery()
  340. myTrans.Commit()
  341. Console.WriteLine("Both records are written to database.")
  342. Catch e As Exception
  343. Try
  344. myTrans.Rollback()
  345. Catch ex As MySqlException
  346. If Not myTrans.Connection Is Nothing Then
  347. Console.WriteLine("An exception of type " + ex.GetType().ToString() + _
  348. " was encountered while attempting to roll back the transaction.")
  349. End If
  350. End Try
  351. Console.WriteLine("An exception of type " + e.GetType().ToString() + _
  352. "was encountered while inserting the data.")
  353. Console.WriteLine("Neither record was written to database.")
  354. Finally
  355. myConnection.Close()
  356. End Try
  357. End Sub
  358. </code>
  359. <code lang="C#">
  360. public void RunTransaction(string myConnString)
  361. {
  362. MySqlConnection myConnection = new MySqlConnection(myConnString);
  363. myConnection.Open();
  364. MySqlCommand myCommand = myConnection.CreateCommand();
  365. MySqlTransaction myTrans;
  366. // Start a local transaction
  367. myTrans = myConnection.BeginTransaction();
  368. // Must assign both transaction object and connection
  369. // to Command object for a pending local transaction
  370. myCommand.Connection = myConnection;
  371. myCommand.Transaction = myTrans;
  372. try
  373. {
  374. myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')";
  375. myCommand.ExecuteNonQuery();
  376. myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')";
  377. myCommand.ExecuteNonQuery();
  378. myTrans.Commit();
  379. Console.WriteLine("Both records are written to database.");
  380. }
  381. catch(Exception e)
  382. {
  383. try
  384. {
  385. myTrans.Rollback();
  386. }
  387. catch (SqlException ex)
  388. {
  389. if (myTrans.Connection != null)
  390. {
  391. Console.WriteLine("An exception of type " + ex.GetType() +
  392. " was encountered while attempting to roll back the transaction.");
  393. }
  394. }
  395. Console.WriteLine("An exception of type " + e.GetType() +
  396. " was encountered while inserting the data.");
  397. Console.WriteLine("Neither record was written to database.");
  398. }
  399. finally
  400. {
  401. myConnection.Close();
  402. }
  403. }
  404. </code>
  405. </example>
  406. </BeginTransaction>
  407. <BeginTransaction1>
  408. <summary>Begins a database transaction with the specified isolation level.</summary>
  409. <param name="iso">The isolation level under which the transaction should run. </param>
  410. <returns>An object representing the new transaction.</returns>
  411. <exception cref="InvalidOperationException">Parallel exceptions are not supported.</exception>
  412. <remarks>
  413. <para>This command is equivalent to the MySQL BEGIN TRANSACTION command.</para>
  414. <para>
  415. You must explicitly commit or roll back the transaction using the <see cref="MySqlTransaction.Commit"/> or
  416. <see cref="MySqlTransaction.Rollback"/> method.
  417. <note>
  418. If you do not specify an isolation level, the default isolation level is used. To specify an isolation
  419. level with the <see cref="BeginTransaction()"/> method, use the overload that takes the <I>iso</I> parameter.
  420. Also note that any attempt to begin a transaction while a transaction is in progress will throw an exception on MySQL 4.1 and higher.
  421. On MySQL 4.0, an exception will not be thrown because servers 4.0 and earlier did not report their transacation status.
  422. </note>
  423. </para>
  424. </remarks>
  425. <example>
  426. The following example creates a <see cref="MySqlConnection"/> and a
  427. <see cref="MySqlTransaction"/>. It also demonstrates how to use the <B>BeginTransaction</B>, a
  428. <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.
  429. <code lang="vbnet">
  430. Public Sub RunTransaction(myConnString As String)
  431. Dim myConnection As New MySqlConnection(myConnString)
  432. myConnection.Open()
  433. Dim myCommand As MySqlCommand = myConnection.CreateCommand()
  434. Dim myTrans As MySqlTransaction
  435. ' Start a local transaction
  436. myTrans = myConnection.BeginTransaction()
  437. ' Must assign both transaction object and connection
  438. ' to Command object for a pending local transaction
  439. myCommand.Connection = myConnection
  440. myCommand.Transaction = myTrans
  441. Try
  442. myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')"
  443. myCommand.ExecuteNonQuery()
  444. myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')"
  445. myCommand.ExecuteNonQuery()
  446. myTrans.Commit()
  447. Console.WriteLine("Both records are written to database.")
  448. Catch e As Exception
  449. Try
  450. myTrans.Rollback()
  451. Catch ex As MySqlException
  452. If Not myTrans.Connection Is Nothing Then
  453. Console.WriteLine("An exception of type " + ex.GetType().ToString() + _
  454. " was encountered while attempting to roll back the transaction.")
  455. End If
  456. End Try
  457. Console.WriteLine("An exception of type " + e.GetType().ToString() + _
  458. "was encountered while inserting the data.")
  459. Console.WriteLine("Neither record was written to database.")
  460. Finally
  461. myConnection.Close()
  462. End Try
  463. End Sub
  464. </code>
  465. <code lang="C#">
  466. public void RunTransaction(string myConnString)
  467. {
  468. MySqlConnection myConnection = new MySqlConnection(myConnString);
  469. myConnection.Open();
  470. MySqlCommand myCommand = myConnection.CreateCommand();
  471. MySqlTransaction myTrans;
  472. // Start a local transaction
  473. myTrans = myConnection.BeginTransaction();
  474. // Must assign both transaction object and connection
  475. // to Command object for a pending local transaction
  476. myCommand.Connection = myConnection;
  477. myCommand.Transaction = myTrans;
  478. try
  479. {
  480. myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')";
  481. myCommand.ExecuteNonQuery();
  482. myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')";
  483. myCommand.ExecuteNonQuery();
  484. myTrans.Commit();
  485. Console.WriteLine("Both records are written to database.");
  486. }
  487. catch(Exception e)
  488. {
  489. try
  490. {
  491. myTrans.Rollback();
  492. }
  493. catch (SqlException ex)
  494. {
  495. if (myTrans.Connection != null)
  496. {
  497. Console.WriteLine("An exception of type " + ex.GetType() +
  498. " was encountered while attempting to roll back the transaction.");
  499. }
  500. }
  501. Console.WriteLine("An exception of type " + e.GetType() +
  502. " was encountered while inserting the data.");
  503. Console.WriteLine("Neither record was written to database.");
  504. }
  505. finally
  506. {
  507. myConnection.Close();
  508. }
  509. }
  510. </code>
  511. </example>
  512. </BeginTransaction1>
  513. <ChangeDatabase>
  514. <summary>Changes the current database for an open MySqlConnection.</summary>
  515. <param name="databaseName">The name of the database to use.</param>
  516. <remarks>
  517. <para>
  518. The value supplied in the <I>database</I> parameter must be a valid database
  519. name. The <I>database</I> parameter cannot contain a null value, an empty
  520. string, or a string with only blank characters.
  521. </para>
  522. <para>
  523. When you are using connection pooling against MySQL, and you close
  524. the connection, it is returned to the connection pool. The next time the
  525. connection is retrieved from the pool, the reset connection request
  526. executes before the user performs any operations.
  527. </para>
  528. </remarks>
  529. <exception cref="ArgumentException">The database name is not valid.</exception>
  530. <exception cref="InvalidOperationException">The connection is not open.</exception>
  531. <exception cref="MySqlException">Cannot change the database.</exception>
  532. <example>
  533. The following example creates a <see cref="MySqlConnection"/> and displays
  534. some of its read-only properties.
  535. <code lang="vbnet">
  536. Public Sub CreateMySqlConnection()
  537. Dim myConnString As String = _
  538. "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"
  539. Dim myConnection As New MySqlConnection( myConnString )
  540. myConnection.Open()
  541. MessageBox.Show( "Server Version: " + myConnection.ServerVersion _
  542. + ControlChars.NewLine + "Database: " + myConnection.Database )
  543. myConnection.ChangeDatabase( "test2" )
  544. MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _
  545. + ControlChars.NewLine + "Database: " + myConnection.Database )
  546. myConnection.Close()
  547. End Sub
  548. </code>
  549. <code lang="C#">
  550. public void CreateMySqlConnection()
  551. {
  552. string myConnString =
  553. "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass";
  554. MySqlConnection myConnection = new MySqlConnection( myConnString );
  555. myConnection.Open();
  556. MessageBox.Show( "Server Version: " + myConnection.ServerVersion
  557. + "\nDatabase: " + myConnection.Database );
  558. myConnection.ChangeDatabase( "test2" );
  559. MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion
  560. + "\nDatabase: " + myConnection.Database );
  561. myConnection.Close();
  562. }
  563. </code>
  564. </example>
  565. </ChangeDatabase>
  566. <StateChange>
  567. <summary>Occurs when the state of the connection changes.</summary>
  568. <remarks>
  569. <para>
  570. The <B>StateChange</B> event fires whenever the <see cref="State"/> changes from
  571. closed to opened, or from opened to closed. <B>StateChange</B> fires immediately
  572. after the <see cref="MySqlConnection"/> transitions.
  573. </para>
  574. <para>
  575. If an event handler throws an exception from within the <B>StateChange</B>
  576. event, the exception propagates to the caller of the <see cref="Open"/> or
  577. <see cref="Close"/> method.
  578. </para>
  579. <para>
  580. The <B>StateChange</B> event is not raised unless you explicitly call
  581. <B>Close</B> or <B>Dispose</B>.
  582. </para>
  583. </remarks>
  584. <event cref="StateChange">
  585. Raised.
  586. <data>
  587. <para>
  588. The event handler receives an argument of type <see cref="System.Data.StateChangeEventArgs"/>
  589. containing data related to this event. The following <B>StateChangeEventArgs</B>
  590. properties provide information specific to this event.
  591. </para>
  592. <list type="table">
  593. <listheader>
  594. <term>Property</term>
  595. <description>Description</description>
  596. </listheader>
  597. <item>
  598. <term>
  599. <see cref="System.Data.StateChangeEventArgs.CurrentState"/>
  600. </term>
  601. <description>
  602. Gets the new state of the connection. The connection object will
  603. be in the new state already when the event is fired.
  604. </description>
  605. </item>
  606. <item>
  607. <term>
  608. <see cref="System.Data.StateChangeEventArgs.OriginalState"/>
  609. </term>
  610. <description>Gets the original state of the connection.</description>
  611. </item>
  612. </list>
  613. </data>
  614. </event>
  615. </StateChange>
  616. <InfoMessage>
  617. <summary>Occurs when MySQL returns warnings as a result of executing a command or query.</summary>
  618. <remarks>
  619. </remarks>
  620. </InfoMessage>
  621. <ClassSummary>
  622. <summary>
  623. Represents an open connection to a MySQL Server database. This class cannot be inherited.
  624. </summary>
  625. <remarks>
  626. <para>
  627. A <b>MySqlConnection</b> object represents a session to a MySQL Server
  628. data source. When you create an instance of <B>MySqlConnection</B>, all
  629. properties are set to their initial values. For a list of these values, see the
  630. <B>MySqlConnection</B> constructor.
  631. </para>
  632. <para>
  633. If the <B>MySqlConnection</B> goes out of scope, it is not closed. Therefore,
  634. you must explicitly close the connection by calling <see cref="MySqlConnection.Close"/>
  635. or <see cref="MySqlConnection.Dispose()"/>.
  636. </para>
  637. </remarks>
  638. <example>
  639. The following example creates a <see cref="MySqlCommand"/> and
  640. a <B>MySqlConnection</B>. The <B>MySqlConnection</B> is opened and set as the
  641. <see cref="MySqlCommand.Connection"/> for the <B>MySqlCommand</B>. The example then calls
  642. <see cref="MySqlCommand.ExecuteNonQuery"/>, and closes the connection. To accomplish this, the <B>ExecuteNonQuery</B> is
  643. passed a connection string and a query string that is a SQL INSERT
  644. statement.
  645. <code lang="vbnet">
  646. <c>
  647. Public Sub InsertRow(myConnectionString As String)
  648. ' If the connection string is null, use a default.
  649. If myConnectionString = "" Then
  650. myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"
  651. End If
  652. Dim myConnection As New MySqlConnection(myConnectionString)
  653. Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"
  654. Dim myCommand As New MySqlCommand(myInsertQuery)
  655. myCommand.Connection = myConnection
  656. myConnection.Open()
  657. myCommand.ExecuteNonQuery()
  658. myCommand.Connection.Close()
  659. End Sub
  660. </c>
  661. </code>
  662. <code lang="C#">
  663. <c>
  664. public void InsertRow(string myConnectionString)
  665. {
  666. // If the connection string is null, use a default.
  667. if(myConnectionString == "")
  668. {
  669. myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass";
  670. }
  671. MySqlConnection myConnection = new MySqlConnection(myConnectionString);
  672. string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)";
  673. MySqlCommand myCommand = new MySqlCommand(myInsertQuery);
  674. myCommand.Connection = myConnection;
  675. myConnection.Open();
  676. myCommand.ExecuteNonQuery();
  677. myCommand.Connection.Close();
  678. }
  679. </c>
  680. </code>
  681. </example>
  682. </ClassSummary>
  683. <ConnectionTimeout>
  684. <summary>
  685. Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
  686. </summary>
  687. <exception cref="System.ArgumentException">The value set is less than 0.</exception>
  688. <remarks>
  689. A value of 0 indicates no limit, and should be avoided in a
  690. <see cref="MySqlConnection.ConnectionString"/> because an attempt to connect
  691. will wait indefinitely.
  692. </remarks>
  693. <example>
  694. The following example creates a MySqlConnection
  695. and sets some of its properties in the connection string.
  696. <code lang="vbnet">
  697. Public Sub CreateSqlConnection()
  698. Dim myConnection As New MySqlConnection()
  699. myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"
  700. myConnection.Open()
  701. End Sub
  702. </code>
  703. <code lang="C#">
  704. public void CreateSqlConnection()
  705. {
  706. MySqlConnection myConnection = new MySqlConnection();
  707. myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30";
  708. myConnection.Open();
  709. }
  710. </code>
  711. </example>
  712. </ConnectionTimeout>
  713. <ConnectionString>
  714. <summary>
  715. Gets or sets the string used to connect to a MySQL Server database.
  716. </summary>
  717. <remarks>
  718. <para>
  719. The <B>ConnectionString</B> returned may not be exactly like what was originally
  720. set but will be indentical in terms of keyword/value pairs. Security information
  721. will not be included unless the Persist Security Info value is set to true.
  722. </para>
  723. <para>
  724. You can use the <B>ConnectionString</B> property to connect to a database.
  725. The following example illustrates a typical connection string.
  726. </para>
  727. <c>"Persist Security Info=False;database=MyDB;server=MySqlServer;user id=myUser;Password=myPass"</c>
  728. <para>
  729. The <B>ConnectionString</B> property can be set only when the connection is
  730. closed. Many of the connection string values have corresponding read-only
  731. properties. When the connection string is set, all of these properties are
  732. updated, except when an error is detected. In this case, none of the properties
  733. are updated. <see cref="MySqlConnection"/> properties return only those settings contained in the
  734. <B>ConnectionString</B>.
  735. </para>
  736. <para>
  737. To connect to a local machine, specify "localhost" for the server. If you do not
  738. specify a server, localhost is assumed.
  739. </para>
  740. <para>
  741. Resetting the <B>ConnectionString</B> on a closed connection resets all
  742. connection string values (and related properties) including the password. For
  743. example, if you set a connection string that includes "Database= MyDb", and
  744. then reset the connection string to "Data Source=myserver;User Id=myUser;Password=myPass",
  745. the <see cref="MySqlConnection.Database"/> property is no longer set to MyDb.
  746. </para>
  747. <para>
  748. The connection string is parsed immediately after being set. If errors in
  749. syntax are found when parsing, a runtime exception, such as <see cref="ArgumentException"/>,
  750. is generated. Other errors can be found only when an attempt is made to open the
  751. connection.
  752. </para>
  753. <para>
  754. The basic format of a connection string consists of a series of keyword/value
  755. pairs separated by semicolons. The equal sign (=) connects each keyword and its
  756. value. To include values that contain a semicolon, single-quote character, or
  757. double-quote character, the value must be enclosed in double quotes. If the
  758. value contains both a semicolon and a double-quote character, the value can be
  759. enclosed in single quotes. The single quote is also useful if the value begins
  760. with a double-quote character. Conversely, the double quote can be used if the
  761. value begins with a single quote. If the value contains both single-quote and
  762. double-quote characters, the quote character used to enclose the value must be
  763. doubled each time it occurs within the value.
  764. </para>
  765. <para>
  766. To include preceding or trailing spaces in the string value, the value must
  767. be enclosed in either single quotes or double quotes. Any leading or trailing
  768. spaces around integer, Boolean, or enumerated values are ignored, even if
  769. enclosed in quotes. However, spaces within a string literal keyword or value are
  770. preserved. Using .NET Framework version 1.1, single or double quotes may be used
  771. within a connection string without using delimiters (for example, Data Source=
  772. my'Server or Data Source= my"Server), unless a quote character is the first or
  773. last character in the value.
  774. </para>
  775. <para>
  776. To include an equal sign (=) in a keyword or value, it must be preceded by
  777. another equal sign. For example, in the hypothetical connection string
  778. </para>
  779. <c>"key==word=value"</c>
  780. <para></para>
  781. <para>the keyword is "key=word" and the value is "value".</para>
  782. <para>
  783. If a specific keyword in a keyword= value pair occurs multiple times in a
  784. connection string, the last occurrence listed is used in the value set.
  785. </para>
  786. <para>Keywords are not case sensitive.</para>
  787. <para>
  788. The following table lists the valid names for keyword values within the
  789. <B>ConnectionString</B>.
  790. </para>
  791. <div class="tablediv">
  792. <table class="dtTABLE" cellspacing="0">
  793. <tr valign="top">
  794. <th width="33%">Name</th>
  795. <th width="33%">Default</th>
  796. <th width="33%">Description</th>
  797. </tr>
  798. <tr>
  799. <td>
  800. Connect Timeout<para> -or- </para>Connection Timeout
  801. </td>
  802. <td>15</td>
  803. <td>
  804. The length of time (in seconds) to wait for a connection to the server before
  805. terminating the attempt and generating an error.
  806. </td>
  807. </tr>
  808. <tr>
  809. <td>
  810. Host<para> -or- </para>Server<para> -or- </para>Data Source<para> -or- </para>
  811. DataSource<para> -or- </para>Address<para> -or- </para>Addr<para> -or- </para>
  812. Network Address
  813. </td>
  814. <td>localhost</td>
  815. <td>
  816. <para>
  817. The name or network address of the instance of MySQL to which to connect. Multiple hosts can be
  818. specified separated by &amp;. This can be useful where multiple MySQL servers are configured for replication
  819. and you are not concerned about the precise server you are connecting to. No attempt is made by the provider to
  820. synchronize writes to the database so care should be taken when using this option.
  821. </para>
  822. <para>
  823. In Unix environment with Mono, this can be a fully qualified path to MySQL socket filename. With this configuration, the Unix socket will be used instead of TCP/IP socket.
  824. Currently only a single socket name can be given so accessing MySQL in a replicated environment using Unix sockets is not currently supported.
  825. </para>
  826. </td>
  827. </tr>
  828. <tr>
  829. <td>Port</td>
  830. <td>3306</td>
  831. <td>
  832. The port MySQL is using to listen for connections. This value is ignored if the connection protocol
  833. is anything but socket.
  834. </td>
  835. </tr>
  836. <tr>
  837. <td>Protocol</td>
  838. <td>socket</td>
  839. <td>
  840. Specifies the type of connection to make to the server.<para>Values can be:</para>
  841. socket or tcp for a socket connection<br/>
  842. pipe for a named pipe connection<br/>
  843. unix for a Unix socket connection<br/>
  844. memory to use MySQL shared memory
  845. </td>
  846. </tr>
  847. <tr>
  848. <td>
  849. CharSet<para> -or </para>Character Set
  850. </td>
  851. <td></td>
  852. <td>
  853. Specifies the character set that should be used to encode all queries sent to the server.
  854. Resultsets are still returned in the character set of the data returned.
  855. </td>
  856. </tr>
  857. <tr>
  858. <td>Logging</td>
  859. <td>false</td>
  860. <td>When true, various pieces of information is output to any configured TraceListeners.</td>
  861. </tr>
  862. <tr>
  863. <td>Allow Batch</td>
  864. <td>true</td>
  865. <td>
  866. When true, multiple SQL statements can be sent with one command execution.<br/><br/>
  867. -Note-<br/>
  868. Starting with MySQL 4.1.1, batch statements should be separated by the server-defined seperator character.<br/>
  869. Commands sent to earlier versions of MySQL should be seperated with ';'.
  870. </td>
  871. </tr>
  872. <tr>
  873. <td>Encrypt</td>
  874. <td>false</td>
  875. <td>
  876. When <B>true</B>, SSL/TLS encryption is used for all data sent between the
  877. client and server if the server has a certificate installed. Recognized values
  878. are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.
  879. </td>
  880. </tr>
  881. <tr>
  882. <td>
  883. Initial Catalog<para> -or- </para>Database
  884. </td>
  885. <td>mysql</td>
  886. <td>The name of the database to use intially</td>
  887. </tr>
  888. <tr>
  889. <td>
  890. Password<para> -or- </para>pwd
  891. </td>
  892. <td></td>
  893. <td>The password for the MySQL account being used.</td>
  894. </tr>
  895. <tr>
  896. <td>Persist Security Info</td>
  897. <td>false</td>
  898. <td>
  899. When set to <B>false</B> or <B>no</B> (strongly recommended), security-sensitive
  900. information, such as the password, is not returned as part of the connection if
  901. the connection is open or has ever been in an open state. Resetting the
  902. connection string resets all connection string values including the password.
  903. Recognized values are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.
  904. </td>
  905. </tr>
  906. <tr>
  907. <td>
  908. User Id<para> -or- </para>Username<para> -or- </para>Uid<para> -or- </para>User name
  909. </td>
  910. <td></td>
  911. <td>The MySQL login account being used.</td>
  912. </tr>
  913. <tr>
  914. <td>Shared Memory Name</td>
  915. <td>MYSQL</td>
  916. <td>The name of the shared memory object to use for communication if the connection protocol is set to memory.</td>
  917. </tr>
  918. <tr>
  919. <td>Allow Zero Datetime</td>
  920. <td>false</td>
  921. <td>
  922. True to have MySqlDataReader.GetValue() return a MySqlDateTime for date or datetime columns that have illegal values.
  923. False will cause a DateTime object to be returned for legal values and an exception will be thrown for illegal values.
  924. </td>
  925. </tr>
  926. <tr>
  927. <td>Convert Zero Datetime</td>
  928. <td>false</td>
  929. <td>
  930. True to have MySqlDataReader.GetValue() and MySqlDataReader.GetDateTime()
  931. return DateTime.MinValue for date or datetime columns that have illegal values.
  932. </td>
  933. </tr>
  934. <tr>
  935. <td>
  936. Pipe Name<para> -or- </para>Pipe
  937. </td>
  938. <td>mysql</td>
  939. <td>
  940. When set to the name of a named pipe, the <B>MySqlConnection</B> will attempt to connect to MySQL
  941. on that named pipe.<br/><br/>This settings only applies to the Windows platform.
  942. </td>
  943. </tr>
  944. <tr>
  945. <td>
  946. Use Performance Monitor<para> -or- </para>UsePerformanceMonitor
  947. </td>
  948. <td>false</td>
  949. <td>
  950. Posts performance data that can be tracked using perfmon
  951. </td>
  952. </tr>
  953. <tr>
  954. <td>
  955. Procedure Cache Size
  956. </td>
  957. <td>25</td>
  958. <td>
  959. How many stored procedure definitions can be held in the cache
  960. </td>
  961. </tr>
  962. <tr>
  963. <td>
  964. Ignore Prepare
  965. </td>
  966. <td>true</td>
  967. <td>
  968. Instructs the provider to ignore any attempts to prepare commands. This option
  969. was added to allow a user to disable prepared statements in an entire application
  970. without modifying the code. A user might want to do this if errors or bugs are
  971. encountered with MySQL prepared statements.
  972. </td>
  973. </tr>
  974. <tr>
  975. <td>Use Procedure Bodies</td>
  976. <td>true</td>
  977. <td>
  978. Instructs the provider to attempt to call the procedure without first resolving the metadata. This
  979. is useful in situations where the calling user does not have access to the mysql.proc table. To
  980. use this mode, the parameters for the procedure must be added to the command in the same order
  981. as they appear in the procedure definition and their types must be explicitly set.
  982. </td>
  983. </tr>
  984. <tr>
  985. <td>Auto Enlist</td>
  986. <td>true</td>
  987. <td>
  988. Indicates whether the connection should automatically enlist in the current transaction,
  989. if there is one.
  990. </td>
  991. </tr>
  992. <tr>
  993. <td>Respect Binary Flags</td>
  994. <td>true</td>
  995. <td>
  996. Indicates whether the connection should respect all binary flags sent to the client
  997. as part of column metadata. False will cause the connector to behave like
  998. Connector/Net 5.0 and earlier.
  999. </td>
  1000. </tr>
  1001. <tr>
  1002. <td>BlobAsUTF8IncludePattern</td>
  1003. <td>null</td>
  1004. <td>
  1005. Pattern that should be used to indicate which blob columns should be treated as UTF-8.
  1006. </td>
  1007. </tr>
  1008. <tr>
  1009. <td>BlobAsUTF8ExcludePattern</td>
  1010. <td>null</td>
  1011. <td>
  1012. Pattern that should be used to indicate which blob columns should not be treated as UTF-8.
  1013. </td>
  1014. </tr>
  1015. <tr>
  1016. <td>Default Command Timeout</td>
  1017. <td>30</td>
  1018. <td>
  1019. The default timeout that new MySqlCommand objects will use unless changed.
  1020. </td>
  1021. </tr>
  1022. <tr>
  1023. <td>Allow User Variables</td>
  1024. <td>false</td>
  1025. <td>
  1026. Should the provider expect user variables in the SQL.
  1027. </td>
  1028. </tr>
  1029. <tr>
  1030. <td>Interactive -or- Interactive Session</td>
  1031. <td>false</td>
  1032. <td>
  1033. Should this session be considered interactive?
  1034. </td>
  1035. </tr>
  1036. <tr>
  1037. <td>Functions Return String</td>
  1038. <td>false</td>
  1039. <td>
  1040. Set this option to true to force the return value of SQL functions to be string.
  1041. </td>
  1042. </tr>
  1043. <tr>
  1044. <td>Use Affected Rows</td>
  1045. <td>false</td>
  1046. <td>
  1047. Set this option to true to cause the affected rows reported to reflect only the
  1048. rows that are actually changed. By default, the number of rows that are matched
  1049. is returned.
  1050. </td>
  1051. </tr>
  1052. </table>
  1053. </div>
  1054. <para>
  1055. The following table lists the valid names for connection pooling values within
  1056. the <B>ConnectionString</B>. For more information about connection pooling, see
  1057. Connection Pooling for the MySql Data Provider.
  1058. </para>
  1059. <div class="tablediv">
  1060. <table class="dtTABLE" cellspacing="0">
  1061. <tr valign="top">
  1062. <th width="33%">Name</th>
  1063. <th width="33%">Default</th>
  1064. <th width="33%">Description</th>
  1065. </tr>
  1066. <tr>
  1067. <td>Connection Lifetime</td>
  1068. <td>0</td>
  1069. <td>
  1070. When a connection is returned to the pool, its creation time is compared with
  1071. the current time, and the connection is destroyed if that time span (in seconds)
  1072. exceeds the value specified by <B>Connection Lifetime</B>. This is useful in
  1073. clustered configurations to force load balancing between a running server and a
  1074. server just brought online.
  1075. <para>
  1076. A value of zero (0) causes pooled connections to have the maximum connection
  1077. timeout.
  1078. </para>
  1079. </td>
  1080. </tr>
  1081. <tr>
  1082. <td>Max Pool Size</td>
  1083. <td>100</td>
  1084. <td>The maximum number of connections allowed in the pool.</td>
  1085. </tr>
  1086. <tr>
  1087. <td>Min Pool Size</td>
  1088. <td>0</td>
  1089. <td>The minimum number of connections allowed in the pool.</td>
  1090. </tr>
  1091. <tr>
  1092. <td>Pooling</td>
  1093. <td>true</td>
  1094. <td>
  1095. When <B>true</B>, the <B>MySqlConnection</B> object is drawn from the appropriate
  1096. pool, or if necessary, is created and added to the appropriate pool. Recognized
  1097. values are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.
  1098. </td>
  1099. </tr>
  1100. <tr>
  1101. <td>Connection Reset</td>
  1102. <td>false</td>
  1103. <td>
  1104. Specifies whether the database connection should be reset when being
  1105. drawn from the pool. Leaving this as <b>false</b> will yeild much faster
  1106. connection opens but the user should understand the side effects
  1107. of doing this such as temporary tables and user variables from the previous
  1108. session not being cleared out.
  1109. </td>
  1110. </tr>
  1111. <tr>
  1112. <td>Cache Server Properties</td>
  1113. <td>false</td>
  1114. <td>
  1115. Specifies whether the server variables are cached between pooled connections.
  1116. On systems where the variables change infrequently and there are lots of
  1117. connection attempts, this can speed up things dramatically.
  1118. </td>
  1119. </tr>
  1120. </table>
  1121. </div>
  1122. <para>
  1123. When setting keyword or connection pooling values that require a Boolean
  1124. value, you can use 'yes' instead of 'true', and 'no' instead of 'false'.
  1125. </para>
  1126. <para>
  1127. <B>Note</B> The MySql Data Provider uses the native socket protocol to
  1128. communicate with MySQL. Therefore, it does not support the use of an ODBC data source name (DSN) when
  1129. connecting to MySQL because it does not add an ODBC layer.
  1130. </para>
  1131. <para>
  1132. <B>CAUTION</B> In this release, the application should use caution when constructing a
  1133. connection string based on user input (for example when retrieving user ID and password information from a
  1134. dialog box, and appending it to the connection string). The application should
  1135. ensure that a user cannot embed extra connection string parameters in these
  1136. values (for example, entering a password as "validpassword;database=somedb" in
  1137. an attempt to attach to a different database).
  1138. </para>
  1139. </remarks>
  1140. <example>
  1141. The following example creates a <see cref="MySqlConnection"/> and sets some of its properties
  1142. <code lang="vbnet">
  1143. Public Sub CreateConnection()
  1144. Dim myConnection As New MySqlConnection()
  1145. myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass"
  1146. myConnection.Open()
  1147. End Sub 'CreateConnection
  1148. </code>
  1149. <code lang="C#">
  1150. public void CreateConnection()
  1151. {
  1152. MySqlConnection myConnection = new MySqlConnection();
  1153. myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass";
  1154. myConnection.Open();
  1155. }
  1156. </code>
  1157. </example>
  1158. <example>
  1159. The following example creates a <see cref="MySqlConnection"/> in Unix environment with Mono installed. MySQL socket filename used in this example is "/var/lib/mysql/mysql.sock". The actual filename depends on your MySQL configuration.
  1160. <code lang="vbnet">
  1161. Public Sub CreateConnection()
  1162. Dim myConnection As New MySqlConnection()
  1163. myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass"
  1164. myConnection.Open()
  1165. End Sub 'CreateConnection
  1166. </code>
  1167. <code lang="C#">
  1168. public void CreateConnection()
  1169. {
  1170. MySqlConnection myConnection = new MySqlConnection();
  1171. myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass";
  1172. myConnection.Open();
  1173. }
  1174. </code>
  1175. </example>
  1176. </ConnectionString>
  1177. <ClearPool>
  1178. <summary>Empties the connection pool associated with the specified connection.</summary>
  1179. <param name="connection">
  1180. The <see cref="MySqlConnection"/> associated with the pool to be cleared.
  1181. </param>
  1182. <remarks>
  1183. <para>
  1184. ClearPool clears the connection pool that is associated with the connection.
  1185. If additional connections associated with connection are in use at the time of the call,
  1186. they are marked appropriately and are discarded (instead of being returned to the pool)
  1187. when Close is called on them.
  1188. </para>
  1189. </remarks>
  1190. </ClearPool>
  1191. <ClearAllPools>
  1192. <summary>Clears all connection pools.</summary>
  1193. <remarks>
  1194. <para>
  1195. ClearAllPools essentially performs a <see cref="ClearPool"/> on all current connection
  1196. pools.
  1197. </para>
  1198. </remarks>
  1199. </ClearAllPools>
  1200. </docs>