asp.net 批量更新
public bool UpdateInventory(DataTable dt,string user)
{
using (SqlConnection connection = new SqlConnection(DBUtility.DbHelperSQL.connectionString))
{
SqlDataAdapter da = new SqlDataAdapter();
da.UpdateCommand = new SqlCommand("Update Inventory set LogisticsNumber=@LogisticsNumber, ModifyBy='" + user + "',ModifyDate= getdate() where InventoryID=@InventoryID", connection);
da.UpdateCommand.Parameters.Add(new SqlParameter("@LogisticsNumber", SqlDbType.NVarChar, 50, "LogisticsNumber"));
da.UpdateCommand.Parameters.Add(new SqlParameter("@InventoryID", SqlDbType.UniqueIdentifier, 50, "InventoryID"));
connection.Open();
int rows = da.Update(dt);
connection.Close();
return rows > 0;
}
}