• 批处理DataTable


     DataTable dt = CreateTable();          

       SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Test;Integrated Security=True");    

             SqlCommand myCommand = new SqlCommand("update sqlcommand set sname='@sname' where sid=@sid  ", (SqlConnection)conn);

                SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);

                SqlCommandBuilder myCommandBuilder = new SqlCommandBuilder(myAdapter);

                myAdapter.UpdateCommand = myCommandBuilder.GetUpdateCommand();        

                 try             {         

            lock (this)                              //处理并发情况(分布式情况        

             {                     conn.Open();

                        myAdapter.Update(dt);

                        conn.Close();         

            }       

          }          

       catch(Exception se)          

       {            

    Response.Write(se.Message);        

         }

    public DataTable CreateTable()
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("sname");
                dt.Columns.Add("sid");
                DataRow dr = dt.NewRow();
                dr["sname"] = "tx";
                dr["sid"] = "1";
                dt.Rows.Add(dr);
                DataRow drs = dt.NewRow();
                drs["sname"] = "John";
                drs["sid"] = "3";
                dt.Rows.Add(drs);
                return dt;
            }

  • 相关阅读:
    nodejs初期,搭建一个登陆注册功能,(原生的)
    关于vue如何创建一个自定义组件(这是项目中经常得用的)
    关于vue 使用watch方法,详解。
    怎样用Nodejs搭建一个服务器
    关于Promise的理解及运用
    Ado.NET SQLHelper(2)
    Ado.NET SQLHelper
    MS SQLSERVER 自增ID列竟然会重复
    SQL中Left Join 与Right Join 与 Inner Join 与 Full Join的区别
    thread.start和threadstart.invoke的区别
  • 原文地址:https://www.cnblogs.com/tx720/p/3452943.html
Copyright © 2020-2023  润新知