DataAdapter的Update( DS , "表名" )会自动将数据表的行状态更新为Unchanged状态,怎么才能去掉这个功能。我想手动更新行状态。
我举例说一下必要性: 
 我一次更新两个DataTable,问题出来了。 
 private   int   UpdateDT() 
 { 
       try 
             { 
                   DataAdapter.Update(   DT1   )   //第1步 
                   DataAdapter.Update(   DT2   )   //第2步 
                   //当然,有事务提交语句,为了方便没有写出 
                   return   0;//成功。 
             } 
       catch 
          { 
                   //当然,有事务回滚语句,为了方便没有写出 
                   return   -1;//失败 
          } 
 } 
 第1步成功了,第2步失败了。此时DT1的行状态都成Unchanged,DT2的行状态没有变。   
 如果再次调用UpdateDT(),就会产生错误,第1步没有任何操作,而第2步执行成功了。 
 那么整个操作就数据没有同步。
------解决方案--------------------试试 
 SqlDataAdapter da = new SqlDataAdapter(sSql,dbConn); 
 da.MissingSchemaAction = MissingSchemaAction.AddWithKey; 
 SqlCommandBuilder cb = new SqlCommandBuilder(da); 
 da.InsertCommand = cb.GetInsertCommand(); 
 da.UpdateCommand = cb.GetUpdateCommand(); 
 da.DeleteCommand = cb.GetDeleteCommand();