sisibest

导航

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;
            }

        }

posted on 2013-01-21 17:33  sisibest  阅读(128)  评论(0编辑  收藏  举报