Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Connection Pooling with MySqlDataAdapter InsertCommand (no replies)

$
0
0
Hi all,
I just read and applied the suggestions found on this article http://dev.mysql.com/doc/refman/5.0/en/connector-net-programming-connection-pooling.html about using always the connection string instead of a global accessible MySqlConnection.

This works fine for all use cases I have found so far but I cannot find a solution to use a connection from the pool when setting InsertCommand of a MySqlDataAdapter.

If you want to use a custom insert command when using MySqlDataAdapter you have to create a MySqlCommand and assign it to InsertCommand property of the MySqlDataAdapter.
MySqlCommand doesn't have any overloaded method that takes a connection string instead of the actual MySqlConnection.

I am using Connector 6.2.3, I cannot use a later version as for the time being I am bound to MySql 4.

following an extract of the current code


Dim adapter As MySqlDataAdapter = New MySqlDataAdapter(queryString, _connectionString)
Dim insCommand As MySqlCommand = New MySqlCommand(insertStatement, _connection) '_connection has to be the actual MySqlConnection
insCommand.Parameters.Add("?field1", MySqlDbType.Int32, 16, "field1")
insCommand.Parameters.Add("?field2", MySqlDbType.Int32, 16, "field2")
adapter.InsertCommand = insCommand

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>