SqlDataAdapter da = new SqlDataAdapter(...);
new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
......
对ds的修改操作
......
da.Update(ds)
new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
......
对ds的修改操作
......
da.Update(ds)
DataSet会将修改后的数据传回修改的!
SqlDataAdapter对象自动判断出那些纪录发生了变动。
还是在
对ds的修改操作和da.Update(ds)之间还有一些必须的代码。
我如上写过后好像有问题。
能给出更详细的代码吗。最好是你们开发过的已验证过的源代码。
先谢过了。
new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
......
//例如,新增一条记录
DataRow dr = ds.Table[0].NewRow();
dr["id"]=xxx;
dr["name"]=XXX;
......
ds.Table[0].Row.Add(dr);
......
da.Update(ds);
//update之后 数据库里有了新的记录