Bug #5474 cannot run a stored procedure populating mysqlcommand.parameters
Submitted: 8 Sep 2004 14:47 Modified: 8 Sep 2004 16:08
Reporter: Emanuele Scozzafava Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:1.0.0 beta OS:Windows (Windows XP Pro)
Assigned to: Reggie Burnett CPU Architecture:Any

[8 Sep 2004 14:47] Emanuele Scozzafava
Description:
When a stored procedure is called using a mysqlcommand
- populating its parameters collection -
an error occurs:
#42000Incorrect number of arguments for PROCEDURE sp_test; expected 1; got 0

this is the stack trace for mysqlexception object:
   at MySql.Data.MySqlClient.Driver.ReadPacket()
   at MySql.Data.MySqlClient.Driver.Send(DBCmd cmd, Byte[] bytes)
   at MySql.Data.MySqlClient.InternalConnection.ExecuteCmd(DBCmd cmd, Byte[] buffer, Boolean consume)
   at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
   at WindowsApplicationTest.Form1.button1_Click(Object sender, EventArgs e) in c:\\documents and settings\\elabora_46\\documenti\\progetti di visual studio\\windowsapplicationtest\\form1.cs:line 261

mysql server version: 5.0.1 alpha.
The sp functions correctly into mysql client.

How to repeat:
create this simple stored procedure on MySql Server 5.0.1 alpha:
CREATE PROCEDURE sp_test(par0 int)
begin
	select par0;
end

then run this code:

MySqlConnection cn = new MySqlConnection();
cn.ConnectionString = "Data Source=localhost;database=testdb;";
cn.Open();

MySqlCommand cm = new MySqlCommand();
cm.CommandType = CommandType.StoredProcedure;
cm.Connection = cn;
cm.CommandText = "sp_test";
cm.Parameters.Add("par0", MySqlDbType.Int32).Value = 3;

MySqlDataReader dr = cm.ExecuteReader(CommandBehavior.SingleResult);
[8 Sep 2004 16:08] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html