Asynchronous ExecuteReader (BeginExecuteReader vs. EndExecuteReader)

Asynchronous ExecuteReader (BeginExecuteReader vs. EndExecuteReader)

Postby MrQuinn » Wed 25 Jan 2006 23:07

Hi
When I try this:

Code: Select all
MySqlCommand myCommand = new MySqlCommand("SELECT somecolumns FROM sometable", myConnection);

IAsyncResult cres = myCommand.BeginExecuteReader(null, null, CommandBehavior.Default);

MySqlDataReader myReader = myCommand.EndExecuteReader(cres);


it returns (on EndExecuteReader line) following error message:
Parameter differs from the one returned by BeginExecuteReader method. Parameter name: result

Do you have any idea, where I'm wrong ??
Thanks in advance
MrQuinn
 

Postby Serious » Thu 26 Jan 2006 08:49

We tested you code under .NET Framework 1.0 and .NET Framework 2.0 and found no problems with EndExecuteReader method.
Please specify .NET Framework version, MySQLDirect .NET version you use.
If it is possible please send us small test project. Use address provided in readme file.
Serious
 

Postby MrQuinn » Thu 26 Jan 2006 13:23

After a few hours of experiments and looking in other posts in this forum (kazachok used similar code, thanks) i solved it this way:

myConnection.Open();

DbCommandBase myCommand = new CoreLab.MySql.MySqlCommand("SELECT * FROM cenik ORDER BY cenik_id ", myConnection);
MySqlDataReader myReader = null;
IAsyncResult result = null;
try
{
result = myCommand.BeginExecuteReader(null, null, System.Data.CommandBehavior.Default);

myReader = (MySqlDataReader)myCommand.EndExecuteReader(result);


}

Now it works, but when i wrote my problem, i was trying it in both VS 2003 (.NET 1.1) and VS 2005 (.NET 2)

Thanks for fast response ...
M.
MrQuinn
 


Return to dotConnect for MySQL