我不知道为什么以下查询没有使用我预期的参数执行!
cmdTxt.Append("UPDATE sd32depart SET currentcredit = currentcredit + ? WHERE year = ? AND main_code = ? ");
paramList.Add("currentcredit", value.ToString().TrimEnd());
paramList.Add("year", year.ToString().TrimEnd());
paramList.Add("main_code", main_code.ToString().TrimEnd());
res = ConnectionObj.Execute_NonQueryWithTransaction(cmdTxt.ToString(), CommandType.Text, paramList);
我明白了
res = 1
虽然currentcredit = 180
作为参数
当我检查我的桌子时,我发现了currentcredit NULL
!
public int Execute_NonQueryWithTransaction(string cmdText)
{
string return_msg = "";
int return_val = -1;
//check if connection closed then return -1;
if (connectionstate == ConnectionState.Closed)
return -1;
command.CommandText = cmdText;
command.CommandType = CommandType.Text;
command.Transaction = current_trans;
try
{
return_val = command.ExecuteNonQuery();
}
catch (IfxException ifxEx)// Handle IBM.data.informix : mostly catched
{
return_val = ifxEx.Errors[0].NativeError;
return_msg = return_val.ToString();
}
catch (Exception ex)// Handle all other exceptions.
{
return_msg = ex.Message;
}
finally
{
if (!string.IsNullOrEmpty(return_msg))//catch error
{
//rollback
current_trans.Rollback();
Close_Connection();
}
}
return return_val;
}