这是我的存储过程
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_CPC`(IN _B VARCHAR(100),IN _G VARCHAR(2), IN _R VARCHAR(30), IN _D VARCHAR(30), OUT _C FLOAT, OUT _P FLOAT)
开始 //听到的东西 结束$$
分隔符;
我通过C#流动代码调用这个存储过程
DataSet tmpDataSet = new DataSet();
mCommand.CommandText = "sp_CPC";
mCommand.CommandType = CommandType.StoredProcedure;
// mCommand.CommandText = "sp_select_all_employees";
mCommand.Parameters.AddWithValue("@_B", "bty-23");
mCommand.Parameters.AddWithValue("@_G", "3");
mCommand.Parameters.AddWithValue("@_R", "9000");
mCommand.Parameters.AddWithValue("@_D", "92");
mCommand.Parameters.Add("@_C",SqlDbType.Float);
mCommand.Parameters["@_C"].Direction = ParameterDirection.Output;
mCommand.Parameters.Add("@_P", SqlDbType.Float);
mCommand.Parameters["@_P"].Direction = ParameterDirection.Output;
try
{
mConnection.Open();
mCommand.ExecuteNonQuery();
mAdapter.Fill(tmpDataSet);
}
catch (Exception ex)
{
strErrorInfo = ex.ToString();
}
finally
{
mConnection.Close();
}
return tmpDataSet;
}
显示以下错误 输入字符串的格式不正确。 怎么解决呢
最佳答案
我认为您在以下部分中犯了错误
mCommand.Parameters.Add("@_C",SqlDbType.Float);
mCommand.Parameters["@_C"].Direction = ParameterDirection.Output;
mCommand.Parameters.Add("@_P", SqlDbType.Float);
mCommand.Parameters["@_P"].Direction = ParameterDirection.Output;
将 SqlDbType 更改为 MySqlDbType
mCommand.Parameters.Add("@_C",MySqlDbType.Float);
mCommand.Parameters["@_C"].Direction = ParameterDirection.Output;
mCommand.Parameters.Add("@_P", MySqlDbType.Float);
mCommand.Parameters["@_P"].Direction = ParameterDirection.Output;
关于mysql - 使用 C# 调用存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21595540/