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();
While Executing the statement 'MyCMd.ExecuteNonQuery()' getting error Inupt string was not in correct format ?? [Error On Line ExecuteNonQuery]
Use ExecuteReader
if you need to read the values from the reader
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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.