でパラメーター化されたクエリを使用しようとすると、次の例外に直面しますinformix
。
A character to numeric conversion process failed
StringBuilder sQuery = new StringBuilder();
Dictionary<string, string> paramList = new Dictionary<string, string>();
cmdTxt.Append(" UPDATE userwidgetto SET widget_color = ?, widget_column = ?, widget_order = ?,widget_state = ?,widget_type = ? ");
cmdTxt.Append(" WHERE process_id = ? AND emp_num = ? ");
paramList.Add("process_id", Process_id.ToString());
paramList.Add("emp_num", Emp_num.ToString());
paramList.Add("widget_color", Widget_color.TrimEnd());
paramList.Add("widget_column", Widget_column.ToString().TrimEnd());
paramList.Add("widget_order", Widget_order.ToString());
paramList.Add("widget_state", Widget_state.ToString());
paramList.Add("widget_type", Widget_type.ToString());
affectedRow = DAL_Helper.Execute_NonQuery(cmdTxt.ToString(), CommandType.Text, paramList);
public int Execute_NonQuery(string cmdText, CommandType cmdType, Dictionary<string, string> Param_arr)
{
Open_Connection();
int return_val = -1;
command.CommandText = cmdText;
command.CommandType = cmdType;
command.Transaction = current_trans;
command.Parameters.Clear();
if (Param_arr != null)
{
foreach (KeyValuePair<string, string> parameter in Param_arr)
{
param = command.CreateParameter();
param.ParameterName = parameter.Key.ToString();
if (parameter.Value.ToString() == "Null" || string.IsNullOrEmpty(parameter.Value))
param.Value = DBNull.Value;
else
param.Value = parameter.Value.ToString();
command.Parameters.Add(param);
}
}
try
{
return_val = command.ExecuteNonQuery();//means no error message //OK
}
catch (IfxException ifxEx)// Handle IBM.data.informix : mostly catched
{
return_val = ifxEx.Errors[0].NativeError;
}
catch (Exception Ex)
{
ErrMapping.WriteLog("\r\n" + Ex.Message);
return_val = ExCodeConst;
}
finally
{
Close_Connection();
}
return return_val;
}