MySQLDirect .NET 2.70

MySQLDirect .NET 2.70

Postby cmurialdo » Fri 21 Jan 2005 13:30

I'm testing the MySQLDirect .NET 2.70 data provider on .Net Framework 1.1. When I execute a second datareader on the same connection I get the following exception: CoreLab.MySql.MySqlException: Commands out of sync; You can't run this command now.

It is documented: While the DbDataReader is in use, the associated DbConnection is busy serving the DbDataReader. While in this state, no operations can be performed on the DbConnection except closing.

But, Is there a way to execute multiple datareaders on the same connection as on framework 2.0?.

I have the following code:

MySqlConnection con = new MySqlConnection("UserId=root;Database=test;Host=localhost");
MySqlCommand cmd = new MySqlCommand("select * from cliente1 ", con);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
Console.WriteLine( reader.GetString(1));
MySqlCommand cmd1 = new MySqlCommand("select * from cliente1 ", con);
MySqlDataReader reader1 = cmd1.ExecuteReader();
while (reader1.Read())
Console.WriteLine( reader1.GetString(1));
Posts: 1
Joined: Fri 21 Jan 2005 13:28

Re: MySQLDirect .NET 2.70

Postby Oleg » Mon 24 Jan 2005 09:07

In order to use multiple datareaders you need to create multiple connections with the same connection string (this way is effective due to using connection pool). In other way you can set MySqlCommand.FetchAll property to true.
Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Return to dotConnect for MySQL