我有一个方法来更新 DB2 数据库中的记录:
private void updateRecord()
{
String query = String.Format(@" UPDATE {0}
SET CCDESC = @CCdesc,
CCSDSC = @CCsdsc,
CCNOT1 = @CCnot1,
CCNOT2 = @CCnot2,
CCUDC1 = @CCUdC1,
CCUDC2 = @CCudc2,
CCUDC3 = @CCudc3,
CCRESV = @CCresv,
CCMNDT = @CCMNDT,
CCMNTM = @CCMNTM,
CCMNUS = @User
WHERE CCTabl = @CCTabl AND CCCode = @CCCode"
, table);
Dictionary<String, Object> para = new Dictionary<String, Object>()
{
{"@CCTabl", OLDDetail.TableID},
{"@CCCode", OLDDetail.primaryCode},
{"@CCdesc", detail.tableDescription},
{"@CCsdsc", detail.shortDescription} ,
{"@CCnot1", detail.note1},
{"@CCnot2", detail.note2},
{"@CCUdC1", detail.udc1} ,
{"@CCudc2", detail.udc2} ,
{"@CCudc3", detail.udc3} ,
{"@CCresv", detail.reservation},
{"@CCMNDT", detail.maintainedDate},
{"@CCMNTM", detail.maintainedTime},
{"@User", this.user.username}
};
database.executeQuery(query, para);
}
当我查看数据库时,字段“ CCMNUS ”具有与“ CCMNDT ”相同的值。我不明白为什么会这样。
这是写入服务器的方法:
public void executeQuery(String query, Dictionary<String, Object> para)
{
database.con.Open();
using (database.cmd = new iDB2Command(query, database.con))
{
database.cmd.CommandType = CommandType.Text;
foreach (var value in para)
{
database.cmd.Parameters.AddWithValue(value.Key, value.Value);
}
database.cmd.ExecuteNonQuery();
}
database.con.Close();
}