使用Database.UpdateDataSet方法

// Get default database
Database database = DatabaseFactory.CreateDatabase();

// Read all the customers in a dataset
string selectSql = "SELECT * FROM Customers";
DataSet customerDataSet = database.
ExecuteDataSet(CommandType.Text, selectSql);
// Modify Records foreach (DataRow dr in customerDataSet.Tables[0].Rows) dr["Name"] += "2"; // Create UpdateCommand string updateSql = "UPDATE Customers SET Name = @Name
WHERE CustomerId = @CustomerId
"; DbCommand updateCommand = database.
GetSqlStringCommand(updateSql); database.AddInParameter(updateCommand,
"CustomerId",
DbType.Int32,
"CustomerId", DataRowVersion.Current); database.AddInParameter(updateCommand, "Name",
DbType.String,
"Name", DataRowVersion.Current); // Execute Batch Update // Use zero to specify database // maximum batch update size database.UpdateDataSet(customerDataSet, "Table", null,
updateCommand,
null, UpdateBehavior.Transactional, 0);
posted @ 2011-05-09 18:26  指尖的流星  Views(1500)  Comments(0)    收藏  举报