我正在使用 .Net 框架 4.0。我有这样的源代码:
....
using (MySqlCommand cmd = new MySqlCommand())
{
cmd.Connection = conn;
String query = "SELECT a.process_id, a.prod_dt, a.vlt_dt, a.prod_month, a.karoseri, a.error_flag, a.created_by, date_format(a.created_dt, '%Y%m%d') as created_dt, a.updated_by, date_format(a.updated_dt, '%Y%m%d') as updated_dt FROM tb_t_vlt_web a " +
"WHERE a.process_id = '" + processId + "'";
DataTable dt = CSTDDBUtil.ExecuteQuery(query);
if (dt.Rows.Count > 0)
{
as400Con = CSTDDBUtil.GetAS400Connection();
as400Con.Open();
using (OdbcCommand as400Cmd = new OdbcCommand())
{
as400Cmd.Connection = as400Con;
as400Cmd.CommandText = "INSERT INTO DCDLIB.TBTVLT(VLPRID, VLPRDT, VLVLDT, VLPRMO, VLKRCD, VLERFG, VLCRBY, VLCRDT, VLCHBY, VLCHDT) VALUES " +
"(?,?,?,?,?,?,?,?,?,?)";
foreach (DataRow dr in dt.Rows)
{
as400Cmd.Parameters.Add("1", OdbcType.VarChar).Value = dr["process_id"].ToString();
as400Cmd.Parameters.Add("2", OdbcType.Numeric).Value = dr["prod_dt"];
as400Cmd.Parameters.Add("3", OdbcType.Numeric).Value = dr["vlt_dt"];
as400Cmd.Parameters.Add("4", OdbcType.VarChar).Value = dr["prod_month"].ToString();
as400Cmd.Parameters.Add("5", OdbcType.VarChar).Value = dr["karoseri"].ToString();
as400Cmd.Parameters.Add("6", OdbcType.VarChar).Value = dr["error_flag"].ToString();
as400Cmd.Parameters.Add("7", OdbcType.VarChar).Value = dr["created_by"].ToString();
as400Cmd.Parameters.Add("8", OdbcType.Numeric).Value = dr["created_dt"];
as400Cmd.Parameters.Add("9", OdbcType.VarChar).Value = dr["updated_by"].ToString();
as400Cmd.Parameters.Add("10", OdbcType.Numeric).Value = dr["updated_dt"];
as400Cmd.ExecuteNonQuery();
as400Cmd.Parameters.Clear();
}
as400Cmd.Dispose();
}
}
... Next Process Below ...
当我执行程序时,出现了一个错误as400Cmd.ExecuteNonQuery();
。错误是:
ERROR [00000] [IBM][System i Access ODBC Driver]Column 4: CWB0111 - Input data is too big to fit into field
ERROR [22001] [IBM][System i Access ODBC Driver]Column 4: Character data right truncation.
然后,我检查了AS400,列大小没有问题。
我该如何解决这个错误..?
TBTVLT结构表