日期:2014-05-19  浏览次数:20796 次

搞不定啊,进来帮忙啊!
我用的Microsoft.Practices.EnterpriseLibrary.Data.Oracle;
企业库,oracle数据库,这个没关系主要是现在提示:当传递具有已修改行的   DataRow   集合时,更新要求有效的   UpdateCommand
可是我插入是正常的。
以下插入正常:
DBCommandWrapper   insertCommand   =   db.GetSqlStringCommandWrapper( "insert   into   users(ID,NAME,PWD,IP)   values(:ID,:NAME,:PWD,:IP) ");
insertCommand.AddInParameter( ":ID ",DbType.Int32, "ID ",DataRowVersion.Current);
insertCommand.AddInParameter( ":NAME ",DbType.String, "NAME ",DataRowVersion.Current);
insertCommand.AddInParameter( ":PWD ",DbType.String, "PWD ",DataRowVersion.Current);
insertCommand.AddInParameter( ":IP ",DbType.String, "IP ",DataRowVersion.Current);
DataRow   addedRow   =table.Rows.Add(new   object[]   {GetNewID(),   "New   product ",   "11 ",   "25 "});
int   rowsAffected   =   db.UpdateDataSet(productsDataSet,   "Products ",   insertCommand,null,null,UpdateBehavior.Standard);
以下更新的就出错:
DBCommandWrapper   dbCommand   =   db.GetSqlStringCommandWrapper( "update   users   set   NAME=:NAME,PWD=:PWD,IP=:IP   where   ID=:ID   ");
dbCommand.AddInParameter( ":ID ",DbType.Int32, "ID ",DataRowVersion.Current);
dbCommand.AddInParameter( ":NAME ",DbType.String, "NAME ",DataRowVersion.Current);
dbCommand.AddInParameter( ":PWD ",DbType.String, "PWD ",DataRowVersion.Current);
dbCommand.AddInParameter( ":IP ",DbType.String, "IP ",DataRowVersion.Current);
table.Rows[1][ "NAME "]= "testNAME ";
table.Rows[1][ "PWD "]= "testPWD ";
table.Rows[1][ "IP "]= "testIP ";
int   rowsAffected   =   db.UpdateDataSet(productsDataSet,   "Products ",   null,null,dbCommand,UpdateBehavior.Standard);

------解决方案--------------------
沙发

------解决方案--------------------
没看出什么错误 ! 语句应该没什么问题
帮忙顶
------解决方案--------------------
批量更新
Database db = DatabaseFactory.CreateDatabase();
DataSet productsDataSet = new DataSet();
string sqlCommand = "Select ProductID, ProductName, CategoryID, UnitPrice, LastUpdate From Products ";
DBCommandWrapper dbCommandWrapper = db.GetSqlStringCommandWrapper(sqlCommand);
string productsTable = "Products ";

db.LoadDataSet(dbCommandWrapper, productsDataSet, productsTable);

DataTable table = productsDataSet.Tables[productsTable];
DataRow addedRow = table.Rows.Add(new object[] {DBNull.Value, "New product ", 11, 25});
table.Rows[0][ "ProductName "] = "Modified product ";

DBCommandWrapper insertCommandWrapper = db.GetStoredProcCommandWrapper( "AddProduct ");
insertCommandWrapper.AddInParameter( "@ProductName ", DbType.String, "ProductName ", DataRowVersion.Current);
insertCommandWrapper.AddInParameter( "@CategoryID ", DbType.Int32, "CategoryID ", DataRowVersion.Current);
insertCommandWrapper.AddInParameter( "@UnitPrice ", DbType.Currency, "UnitPrice ", DataRowVersion.Current);

DBCommandWrapper deleteCommandWrapper = db.GetStoredProcCommandWrapper( "DeleteProduct ");
deleteCommandWrapper.AddInParameter( "@ProductID ", DbType.Int32, "ProductID ", DataRowVersion.Current);

DBCommand