dataGridView更新数据

dsfcj dsfcj 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
大家好! 我现在在dataGridView中修改、添加和删除数据,请问我要怎么做才能将更改的数据返回到数据库中?以下是部分代码。愿赐教!
string connstring = @"server=localhost;integrated security=true;database=ps";
SqlConnection conn = new SqlConnection(connstring);
conn.Open();
DataSet ds = new DataSet();
try
{
string sql = @"select * from worker_table where worker_id='" + this.textBox1.Text.Trim() + "'";
SqlDataAdapter sdal = new SqlDataAdapter(sql, conn);
sdal.Fill(ds, "tb1");



BindingSource bs = new BindingSource();
bs.DataMember = "tb1";
bs.DataSource = ds;
this.dataGridView1.DataSource = bs;
}
...全文
评论 12
收藏 已收藏
分享
返回顶部
dsfcj
C# 111,129 成员 642,538 内容