Description:
When calling a routine that has NATIONAL VARCHAR parameters instead of only VARCHAR, this results in a MySqlException "Incorrect number of arguments for PROCEDURE expected 2, got 1" when executing from the .net code.
How to repeat:
Create a procedure with the following MySql Code:
CREATE DEFINER=`root`@`localhost` PROCEDURE `testing`(somepar varchar(100) CHARACTER SET utf8, secondpar varchar(50) CHARACTER SET utf8)
READS SQL DATA
BEGIN
//Some select here
END
From the .net code call the above procedure with the following code:
conn.Open();
var cmd = new MySqlCommand("testing");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn;
string pass = "somepass";
string email = "someemail";
MySqlParameter pramEmail = new MySqlParameter("@somepar", email);
pramEmail.Direction = ParameterDirection.Input;
cmd.Parameters.Add(pramEmail);
MySqlParameter pramPassword = new MySqlParameter("@secondpar", pass);
pramPassword.Direction = ParameterDirection.Input;
cmd.Parameters.Add(pramPassword);
var value = cmd.ExecuteScalar();
conn.Close();
Actual results:
A MySqlException is thrown when Executing the command.
Suggested fix:
Fix the storedprocedure.cs code so all the parameters are correctly added.