Update时出错(高手指导).
我已经绑定了DataGrid,代码如下:
this.ds = link.SelectDataBase(sendStrSQL,"商品清单");//创建数据库连接
this.dgrd_WareData.DataSource = ds.Tables[0];
public DataTable SelectDataBase(string tempStrSQL) //这是用到的函数
{
this.myConnection = new SqlConnection(connectionString);
DataSet tempDataSet = new DataSet();
this.da = new SqlDataAdapter(tempStrSQL,this.myConnection);
this.da.Fill(tempDataSet);
return tempDataSet.Tables[0];
}
上述代码成功显示出了数据到DataGrid中去
当我删除后
this.ds.Tables[0].Rows[intRowNumber].Delete();
this.link.UpdateDataBase(this.ds.GetChanges(),"商品清单");
MessageBox.Show("数据删除成功!","信息");
删除用到这个函数
public DataSet UpdateDataBase(DataSet changedDataSet,string tableName)
{
this.myConnection = new SqlConnection(connectionString);
this.da = new SqlDataAdapter(this.strSQL,this.myConnection);
this.sqlCmdBld = new SqlCommandBuilder(da);
this.da.Update(changedDataSet,tableName);
return changedDataSet;//返回更新了的数据库表
}
当执行到Update时总是出错,高手指教