gpt4 book ai didi

c# - 执行具有多个输出参数的过程时出现错误 'Input String was not in a correct format'

转载 作者:行者123 更新时间:2023-11-29 23:20:15 25 4
gpt4 key购买 nike

            MyCmd = new MySqlCommand("SELECT FnGetTransDate()", MyCon);
MyCon.Open();
MyRead = MyCmd.ExecuteReader();
MyRead.Read();
transdate = Convert.ToDateTime(MyRead.GetValue(0).ToString());
MyRead.Close();
MyCmd = new MySqlCommand("SpGenProcess", MyCon);
MyCmd.CommandType = CommandType.StoredProcedure;
MyCmd.Parameters.AddWithValue("@tempprocessidlist", idlist);
MyCmd.Parameters.AddWithValue("@prdate",Convert.ToDateTime(transdate.ToShortDateString()));
MyCmd.Parameters.AddWithValue("@out_status", MySqlDbType.Int32);
MyCmd.Parameters.AddWithValue("@out_msg", MySqlDbType.VarChar);
MyCmd.Parameters["@out_status"].Direction = ParameterDirection.Output;
MyCmd.Parameters["@out_msg"].Direction = ParameterDirection.Output;
MyCmd.ExecuteNonQuery();
int.TryParse(MyCmd.Parameters["@out_status"].Value.ToString(), out outstatus);
ErMsg = MyCmd.Parameters["@out_msg"].Value.ToString();

执行语句“MyCMd.ExecuteNonQuery()”时出现错误 Inupt 字符串格式不正确?? [在线执行非查询时出错]

最佳答案

如果需要从读取器读取值,请使用ExecuteReader

var reader = MyCmd.ExecuteReader();
if (reader.HasRows)
{
if (reader.Read())
{
int status = (int)reader["out_status"];//breakpoint here
string msg = (string)reader["out_msg"]; //here also
}
}

关于c# - 执行具有多个输出参数的过程时出现错误 'Input String was not in a correct format',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27384407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com