[求助]datagridview的更新和同步问题
我在DATAGRIDVIEW里进行修改,添加,和删除,现在想点一下BUTTON就可以DATAGRIDVIEW里内容更新到数据库里,有人说用DATAGRIDVIEW和DATASET同步,是吗,应该怎么做才可以同步呢,请高手指教~
这是添加的代码,删除和更新大同小异
数据库的表结构很简单,三个字段:xh,xm,cj
private SqlCommand cmm;
private SqlDataAdapter adp;
private DataSet ds;
private SqlParameter p;
cnn = new SqlConnection("server = .; uid = sa; pwd = sqlpass; database = student");
cmm = new SqlCommand("insert into stu values(@xh,@xm,@cj)",cnn);
adp.InsertCommand = cmm;
p = adp.InsertCommand.Parameters.Add("@xh",null);
p.SourceColumn = "xh";
p = adp.InsertCommand.Parameters.Add("@xm",null);
p.SourceColumn = "xm";
p = adp.InsertCommand.Parameters.Add("@cj",null);
p.SourceColumn = "cj";
adp.Update(ds,"stu");