Update时出错(高手指导).

gedeng_2000 gedeng_2000 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我已经绑定了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时总是出错,高手指教
...全文
评论 7
收藏 已收藏
分享
返回顶部
gedeng_2000
C# 111,129 成员 642,539 内容