Getting Commands out of sync; You can't run this command now using 2.70.4.0 version

Getting Commands out of sync; You can't run this command now using 2.70.4.0 version

Postby irfan » Wed 13 Apr 2005 16:57

I have the code below which is throwing the following exception using version 2.70.4.0 of the MySQL CoreLab driver. The command worked just fine using an older version.

A first chance exception of type 'CoreLab.MySql.MySqlException' occurred in corelab.mysql.dll
Additional information: Commands out of sync; You can't run this command now
Code: Select all
// Create a connection.
MySqlConnection sqlConn = new MySqlConnection( connStr );
// Open the connection.
sqlConn.Open();

// Create the SQL string.
string selectSQL = string.Format( "SELECT {0} FROM traversal WHERE traversal_id = '{1}'", colName, traversalID );

// Create the command.
MySqlCommand sqlCmd = new MySqlCommand( selectSQL, sqlConn );

// Create the reader.
MySqlDataReader sqlReader = sqlCmd.ExecuteReader( System.Data.CommandBehavior.SequentialAccess );
irfan
 
Posts: 15
Joined: Wed 13 Apr 2005 00:56

Postby Serious » Thu 14 Apr 2005 08:16

Please check if you close data readers (use try/finally constructions). In the new version of MySQLDirect we have improved protection from data readers that were not closed. Look forward for the next build.
Note that MySQL Server does not support sequential access to fields.
Serious
 

Postby irfan » Thu 14 Apr 2005 16:25

Since the connection is a new connection. I am not sure why closing data readers will impact it.

Version 2.0.5.0 worked fine with the same code. Is it that "CommandBehavior.SequentialAccess" was not enforced or supported in the older driver so it let it continue but the new driver 2.70.4.0 actually throws an exception?

Also, the help file for CoreLab.MySql.MySqlDataReader.ExecuteReader command says
"The MySqlDataReader supports a special mode that enables large binary values to be read efficiently. For more information, see the SequentialAccess setting for CommandBehavior."
I also tried without using the SequentialAccess field and it still throws an exception. (Commands out of sync; You can't run this command now)

Is there any other way to read a large blob directly into a file without having to load the data into memory first using SqlCommand and MySqlDataReader?
irfan
 
Posts: 15
Joined: Wed 13 Apr 2005 00:56

Postby irfan » Fri 15 Apr 2005 17:46

I found out what the problem is. The problem was that the SqlReaders for a previously opened connection was not closed. I would have thought that regardless of whether connection pooling is done or not, when I close a connection, any readers or transactions associated with that connection are either closed or terminated. I see this more as a bug with the driver that the earlier driver 2.0.x did not have.
irfan
 
Posts: 15
Joined: Wed 13 Apr 2005 00:56

Postby Serious » Mon 18 Apr 2005 08:48

There is no way to read a large blob directly into a file on a disk. You have to load it to RAM initially using MySqlCommand and MySqlDataReader. Afterwards you can save it to disk.
Serious
 


Return to dotConnect for MySQL