zoukankan      html  css  js  c++  java
  • DbDataAdapter对象UpdataBatchSize属性批量修改

    private void rowUpdated(object sender, SqlRowUpdatedEventArgs e)
          
    {
             sb.Append(
    "Rows: " + e.RecordsAffected.ToString() + "\r\n");
          }


          
    private void btnUpdateBatch_Click(object sender, EventArgs e)
          
    {
             
    //event subsciption is normally placed in constructor but is here 
             
    //to encapsulate the sample
             da.RowUpdated += new SqlRowUpdatedEventHandler(rowUpdated);
             ConnectionStringSettings pubs 
    = ConfigurationManager.ConnectionStrings["PubsData"];
             DbConnection connection 
    = new SqlConnection(pubs.ConnectionString);
             SqlCommand cmd 
    = (SqlCommand)connection.CreateCommand();
             cmd.CommandType 
    = CommandType.Text;
             cmd.CommandText 
    = "SELECT * FROM Publishers";
             da.SelectCommand 
    = cmd;
             DataSet pubsDataSet 
    = new DataSet("Pubs");
             SqlCommandBuilder bldr 
    = new SqlCommandBuilder(da);
             da.Fill(pubsDataSet, 
    "publishers");
             
    //Modify data here
             foreach (DataRow dr in pubsDataSet.Tables["publishers"].Rows)
             
    {
                dr[
    "pub_name"= "Updated Toys";
             }

             da.UpdateBatchSize 
    =3;
             da.Update(pubsDataSet, 
    "publishers");
             
    //if event subscription is in the contructor, no need to 
             
    //remove it here.
             da.RowUpdated -= new SqlRowUpdatedEventHandler(rowUpdated);
             MessageBox.Show(sb.ToString());
          }
  • 相关阅读:
    Grunt jshint Warning: Path must be a string . Received null Use
    bootstrap滚动监视原理实现
    Bootstrap模态框原理分析及问题解决
    LeetCode54. 螺旋矩阵
    LeetCode53. 最大子序和
    mysql servers实现层拼写SQL
    easyUI 分页 获取页面
    excel导入功能
    easyUI遮罩
    uuid生成
  • 原文地址:https://www.cnblogs.com/zwl12549/p/865089.html
Copyright © 2011-2022 走看看