本人想通过CommandBuilder 编辑 DATAGRIDVIEW  返回数据库 ~ 望给出实例代码!            string sqlstr = "Server =(local);database = SalesManagementSystem;uid =sa;pwd = 123";
            SqlConnection sqlcon = new SqlConnection(sqlstr);
            string str = "select * from T_BasicInformation_Customer";
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = new SqlCommand(str,sqlcon);
            SqlCommandBuilder scb = new SqlCommandBuilder(da);
            if (sqlcon.State == ConnectionState.Closed)
                sqlcon.Open();
            DataSet ds = new DataSet();
            da.Fill(ds, "T_BasicInformation_Customer");
            scb.GetUpdateCommand();
            da.Update(ds,"T_BasicInformation_Customer");望大家指教纠正
你想 Update 什么?从你的代码来看,没有任何数据操作逻辑,只是提取了数据而已。

解决方案 »

  1.   

    执行 DataSet 中的  DataTable 里的每个 DataRow 的 SetAdded 方法;
    把 DataRow 的状态改为 新加的就行了
      

  2.   

    如果想更新就调用 SetModified()
      

  3.   

    DataSet ds = new DataSet();
    SqlDataAdapter sda;SqlCommandBuilder scb = new SqlCommandBuilder(sda);
    sda.Update(ds);
    this.dataGridView1.DataSource = ds.Tables[0];
      

  4.   

    楼上的哥们 ,能完整点嘛  sda可以举个例子吗    哪有资料看 发下也行