Batch Queries
Posted by: Zachary Drummond
Date: November 10, 2004 01:49PM

Hello All;

I am new to MySQL and ADO.NET, but I have a good amount of experience with C#.

I am going through some tutorials and came across batch queries. When I tried the example in the book, the .NET connector gave me an error when it tries to Read() the second table in the result.

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mysql.data.dll
Additional information: Non-negative number required.

I expanded the test, and the problem defiantly seems to be Batch Queries since the individual commands work. Obviously I tried this in MySQl CC and it worked fine. Any help or advice would be appreciated. Here is my test code;

static void Main(string[] args)
{
MySqlConnection connection = new MySqlConnection( "Database=employee;Data Source=localhost;User Id=XXX;Password=XXXX" );
connection.Open();

MySqlCommand employee = conn.CreateCommand();
employee.CommandText = "SELECT * FROM employee;";
MySqlCommand department = conn.CreateCommand();
department.CommandText = "SELECT * FROM department;";
MySqlCommand batch = conn.CreateCommand();
batch.CommandText = "SELECT * FROM employee; SELECT * FROM department;";

OutputReader( employee.ExecuteReader(), "Employee" );
OutputReader( department.ExecuteReader(), "Department" );
OutputReader( batch.ExecuteReader(), "Employee + Department Batch" );

connection.Close();

Console.WriteLine( "Press Enter" );
Console.Read();
}

static void OutputReader( MySqlDataReader reader, String queryName )
{
Console.WriteLine( "[" + queryName + "]" );
do
{
Console.WriteLine( "----------" );
while( reader.Read() ) //This is where the exeception throws on the 2nd tbl in the batch
{
Console.WriteLine( reader["name"] );
}
} while (reader.NextResult());

Console.WriteLine( "----------\n" );

reader.Close();
}


Thanks!
-Zach

Options: ReplyQuote


Subject
Written By
Posted
Batch Queries
November 10, 2004 01:49PM
November 11, 2004 01:35PM
November 17, 2004 07:05PM
November 23, 2004 03:27PM
November 24, 2004 03:05PM
November 30, 2004 04:25PM
November 30, 2004 08:27PM
December 02, 2004 10:08AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.