在C/S中使用了DataGridView,是用控件绑定的,怎么保存修改? 在C/S中使用了DataGridView,是用Dataset、bindingSource、TableAdapter绑定的,现在想在datagrivdView中修改数据,到达修改数据库的效果。 应该怎么做???谢谢指点 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DataAdapter的Update,或者直接通过sql去更改 我试了DataAdapter的Update , 报错了。 能不能给帖个代码 修改完成后将数据取出来,然后更新数据库private void button5_Click(object sender, EventArgs e){//取值dataGridView1.CurrentRow.Cells[i].Value//更新Sql} private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) {SqlConnection conn=new SqlCOnnection(ConnectionString);SqlCommand comd = new SqlCommand(); conn.Open(); str1 = string.Format("update tableA set Name='{0}' where ID={1}",dataGridView1.CurrentRow.CellS["NAME"].Value,dataGridView1.CurrentRow.Cells["id"].Value); comd.Connection = conn; comd.CommandText = str1; comd.ExecuteNonQuery(); conn.Close(); } 直接修改datatable 或者重新绑定 能不能修改dataGridView中的任一条数据之后,保存所有。就是说不管修改那一条数据,也不管修改了多少条数据,一次全部更新的? 可以的。你只要缓存到临时的table,更新时一并更新 这句话在vs中什么意思啊? 为什么同样的sql就不执行呢? 简单问题,找不到正解! 用户控件和母版页调用问题! 高手指教 正则表达式 不能是 hde 三字母相连问题 word转换成html问题,急急!! 创建数据表的问题 大侠们帮帮忙 如何TextBox响应回车键? 经理让我做一个类似于QQ的东东,我不会C#还要做,郁闷... C#串口通讯问题! 定义枚举 怎么在Grid中显示出来~ System.IO.FileNotFoundException: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)
private void button5_Click(object sender, EventArgs e)
{
//取值dataGridView1.CurrentRow.Cells[i].Value
//更新Sql
}
{
SqlConnection conn=new SqlCOnnection(ConnectionString);
SqlCommand comd = new SqlCommand();
conn.Open();
str1 = string.Format("update tableA set Name='{0}' where ID={1}",dataGridView1.CurrentRow.CellS["NAME"].Value,dataGridView1.CurrentRow.Cells["id"].Value);
comd.Connection = conn;
comd.CommandText = str1;
comd.ExecuteNonQuery();
conn.Close();
}
就是说不管修改那一条数据,也不管修改了多少条数据,一次全部更新的?