DataSet怎样更新和删除数据?
?
------解决方案--------------------DateRow newRow=myDs.Tables[ "myTable "].NewRow();
newRow[ "id "]= "111 ";
newRow[ "name "]= "aaa ";
myDs.Tables[ "myTable "].Rows.Add(newRow);
dataset新增记录,其实就是先定义一条新的记录,然后插入到dataset中而已
------解决方案--------------------DataColumn[] keys=new DataColumn[1];
keys[0]=myDs.Tables[ "myTable "].Columns[ "id "];
myDs.Tables[ "myTable "].PrimaryKey=keys;
DataRow findRow=myDs.Tables[ "myTable "].Row.Find( "aaa ");
findRow.Delete();
删除
------解决方案--------------------Rows.Remove()//删除数据行
------解决方案--------------------更新就是在你绑定dataset后,修改某一列的数据,借用一下sleepcraft(越学越不懂)的回复
myDs.Tables[ "myTable "].Columns[ "id "]= "abcd ";