日期:2014-05-18  浏览次数:21163 次

违反并发性: UpdateCommand 影响了预期 1 条记录中的 0 条。
神经了啊!整了一天了还是没有解决
我是将dataset直接插入orcal数据库的时候遇到的问题
System.Data.OracleClient.OracleDataAdapter da = new System.Data.OracleClient.OracleDataAdapter();
  strSql = "select * from " + strTableName;
  System.Data.OracleClient.OracleCommand cm = new System.Data.OracleClient.OracleCommand(strSql, connection);
  da.SelectCommand = cm;
  System.Data.OracleClient.OracleCommandBuilder cb = new System.Data.OracleClient.OracleCommandBuilder(da cb.ConflictOption = System.Data.ConflictOption.OverwriteChanges;
  DataSet ds = new DataSet();
  ds.Tables.Add(dt);
  ds.Tables[0].TableName = strTableName;
  ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["F_ID"] };  
  da.InsertCommand = cb.GetInsertCommand();
  da.UpdateCommand = cb.GetUpdateCommand();
  da.DeleteCommand = cb.GetDeleteCommand();
  lock (this) 
  {
  connection.Open();
  da.Update(ds, strTableName);
  }

声明表有主键是第36列但是
da.UpdateCommand
UPDATE T_BUS SET F_SNUMBER = :p1, F_LICENSE = :p2, F_OPERATIONTYPE = :p3, F_TRACKNO = :p4, F_TEAM = :p5, F_COMPID = :p6, F_FRAMENO = :p7, F_ENGINENO = :p8, F_USETYPE = :p9, F_SURENUM = :p10, F_SUREMASS = :p11, F_DISPLACEMENT = :p12, F_POWER = :p13, F_MODELS = :p14, F_BRAND = :p15, F_CARLENGTH = :p16, F_BUSVES = :p17, F_OUTPUTDT = :p18, F_ISSUBURB = :p19, F_BUYDT = :p20, F_SCRAPPEDDT = :p21, F_MEMO = :p22, F_DEPARTMENTID = :p23, F_ADDNAME = :p24, F_ADDTIME = :p25, F_UPDATENAME = :p26, F_ISSCRAPPED = :p27, F_ISAVAILABLE = :p28, F_TURNFLAG = :p29, F_NODEID = :p30, F_FLOWBUSINESSID = :p31, F_COMMENTS = :p32, F_PASSED = :p33, F_ID = :p34, F_BUSINESSID = :p35, F_BUSNO = :p36, F_UPDATETIME = :p37, F_FLAG = :p38, F_KEY = :p39, F_TURNCOM = :p40 WHERE ((F_ID = :p41))
:p41根本就不存在啊!不对啊啊!
大虾门帮帮忙啊!在线等!

------解决方案--------------------
C# code
da.Update(ds, strTableName);