各位大哥 帮助datagridview 绑定dataset 做数据的修改增加 表是一张表,窗口有两个buttn 一个是update 一个是insert, 在datagridview 中修改数据点update后更新 ,增加行后点击insert 插入请给出详细代码,第一个给出代码调试能用这给满分. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 heh呵呵 网上一大堆的你还是问GOOLGLE最好了 上面都有的 自己搜下了 多动动手了 分有什么用?你直接copy代码有什么用?....最简单的对一张表的维护,insert,update,delete..... string strSqlDel = "delete from 表 where 条件 ";clsSql.Ex(strSqlDel); for (int i = 0; i < this.ucDataGridView1.Rows.Count - 1; i++) { string 编号, 名称, 类别; if (this.ucDataGridView1.Rows[i].Cells[0].Value == null) { 编号 = ""; } else { 编号 = this.ucDataGridView1.Rows[i].Cells[0].Value.ToString(); } if (this.ucDataGridView1.Rows[i].Cells[1].Value == null) { 名称 = ""; } else { 名称 = this.ucDataGridView1.Rows[i].Cells[1].Value.ToString(); } if (this.ucDataGridView1.Rows[i].Cells[2].Value == null) { 类别 = ""; } else { 类别 = this.ucDataGridView1.Rows[i].Cells[2].Value.ToString(); } if (编号 == "" || 名称 == "") { continue; } string strSql = "insert into 表(大类编号,编号,名称,类别) " + "values( " + "'" + no + "','" + 编号 + "','" + 名称 + "','" + 类别 + "')"; clsSql.Ex(strSql); }先删除,再遍历插入,这样的话,2个按钮直接一个按钮就可以了 C#中如何获取dataset的第一条数据,有代码,请帮忙指正 网络(c/s)结构程序运行慢(解决办法和教训总结) 自定义控件中扩展/收缩属性修改后,保存就出错! c# 调用word问题 还是老问题————字符串 C#中能否添加一个低版本的media play控件? c# 端口扫描器 进程问题 datagridview 如何合并表头,不要假合并 各位前辈:在ASP.NET中怎样禁用DATAGRID中列的超链接? 新问题~,readonly和const有什么区别? C++ DLL 调用, 参数类型转换问题 DataSet转成XML的编码问题?
上面都有的 自己搜下了 多动动手了
你直接copy代码有什么用?
....最简单的对一张表的维护,insert,update,delete.....
string strSqlDel = "delete from 表 where 条件 ";
clsSql.Ex(strSqlDel); for (int i = 0; i < this.ucDataGridView1.Rows.Count - 1; i++)
{
string 编号, 名称, 类别; if (this.ucDataGridView1.Rows[i].Cells[0].Value == null)
{
编号 = "";
}
else
{
编号 = this.ucDataGridView1.Rows[i].Cells[0].Value.ToString();
} if (this.ucDataGridView1.Rows[i].Cells[1].Value == null)
{
名称 = "";
}
else
{
名称 = this.ucDataGridView1.Rows[i].Cells[1].Value.ToString();
} if (this.ucDataGridView1.Rows[i].Cells[2].Value == null)
{
类别 = "";
}
else
{
类别 = this.ucDataGridView1.Rows[i].Cells[2].Value.ToString();
} if (编号 == "" || 名称 == "")
{
continue;
}
string strSql = "insert into 表(大类编号,编号,名称,类别) " +
"values( " +
"'" + no + "','" + 编号 + "','" + 名称 + "','" + 类别 +
"')"; clsSql.Ex(strSql); }
先删除,再遍历插入,这样的话,2个按钮直接一个按钮就可以了