J
John Coltrane
I am trying to use parameters for a storedproc with C# and MySQL and I
am getting a null return value.
when I try to run the following snippet I find that the output value is
null. If I run the storedproc in the mysql query app I get a valid
return value. Is there something wrong with the code. btw I also have
found that parameters must be prefixed with '?' instead of '@'.
statement = "my_sqrt";
using ( MySqlCommand command = new MySqlCommand(statement, conn) ) {
command.CommandType = CommandType.StoredProcedure;
MySqlParameter param = new MySqlParameter();
param.ParameterName = "?input_number";
param.MySqlDbType = MySqlDbType.Int32;
param.Value = 9;
param.Direction = ParameterDirection.Input;
command.Parameters.Add(param);
param = new MySqlParameter();
param.ParameterName = "@l_sqrt";
param.MySqlDbType = MySqlDbType.Int32;
param.Direction = ParameterDirection.Output;
command.Parameters.Add(param);
command.ExecuteNonQuery();
if ( command.Parameters[ "?l_sqrt" ].Value == null ) {
Console.WriteLine("null");
}
thanks for the help
john
am getting a null return value.
when I try to run the following snippet I find that the output value is
null. If I run the storedproc in the mysql query app I get a valid
return value. Is there something wrong with the code. btw I also have
found that parameters must be prefixed with '?' instead of '@'.
statement = "my_sqrt";
using ( MySqlCommand command = new MySqlCommand(statement, conn) ) {
command.CommandType = CommandType.StoredProcedure;
MySqlParameter param = new MySqlParameter();
param.ParameterName = "?input_number";
param.MySqlDbType = MySqlDbType.Int32;
param.Value = 9;
param.Direction = ParameterDirection.Input;
command.Parameters.Add(param);
param = new MySqlParameter();
param.ParameterName = "@l_sqrt";
param.MySqlDbType = MySqlDbType.Int32;
param.Direction = ParameterDirection.Output;
command.Parameters.Add(param);
command.ExecuteNonQuery();
if ( command.Parameters[ "?l_sqrt" ].Value == null ) {
Console.WriteLine("null");
}
thanks for the help
john