The following was my code :
public void update2(DataSet myDS)
{
SqlDataAdapter mySqlDataAdapter=new SqlDataAdapter("select * from picfile",myCon);
SqlCommandBuilder objCommand=new SqlCommandBuilder(mySqlDataAdapter);
mySqlDataAdapter.DeleteCommand=objCommand.GetDeleteCommand();
mySqlDataAdapter.InsertCommand=objCommand.GetInsertCommand();
mySqlDataAdapter.UpdateCommand=objCommand.GetUpdateCommand();
myCon.Open();
mySqlDataAdapter.Fill(myDS,"picfile");
SqlTransaction objTransaction=myCon.BeginTransaction();
mySqlDataAdapter.SelectCommand.Transaction=objTransaction;
mySqlDataAdapter.InsertCommand.Transaction=objTransaction;
mySqlDataAdapter.DeleteCommand.Transaction=objTransaction;
mySqlDataAdapter.UpdateCommand.Transaction=objTransaction;
mySqlDataAdapter.TableMappings.Add("picfile","picfile");
mySqlDataAdapter.TableMappings.Add("NodeInfo","nodeinfo");
mySqlDataAdapter.RowUpdating +=new SqlRowUpdatingEventHandler(mySqlDataAdapter_RowUpdating);
mySqlDataAdapter.RowUpdated +=new SqlRowUpdatedEventHandler(mySqlDataAdapter_RowUpdated);
int ttmy=mySqlDataAdapter.Update(myDS,"picfile");
MessageBox.Show(ttmy.ToString());
objTransaction.Commit();
myCon.Close();
}
even the rowUpdating event is not active , I wrote so much ,but I just lost
;-)
public void update2(DataSet myDS)
{
SqlDataAdapter mySqlDataAdapter=new SqlDataAdapter("select * from picfile",myCon);
SqlCommandBuilder objCommand=new SqlCommandBuilder(mySqlDataAdapter);
mySqlDataAdapter.DeleteCommand=objCommand.GetDeleteCommand();
mySqlDataAdapter.InsertCommand=objCommand.GetInsertCommand();
mySqlDataAdapter.UpdateCommand=objCommand.GetUpdateCommand();
myCon.Open();
mySqlDataAdapter.Fill(myDS,"picfile");
SqlTransaction objTransaction=myCon.BeginTransaction();
mySqlDataAdapter.SelectCommand.Transaction=objTransaction;
mySqlDataAdapter.InsertCommand.Transaction=objTransaction;
mySqlDataAdapter.DeleteCommand.Transaction=objTransaction;
mySqlDataAdapter.UpdateCommand.Transaction=objTransaction;
mySqlDataAdapter.TableMappings.Add("picfile","picfile");
mySqlDataAdapter.TableMappings.Add("NodeInfo","nodeinfo");
mySqlDataAdapter.RowUpdating +=new SqlRowUpdatingEventHandler(mySqlDataAdapter_RowUpdating);
mySqlDataAdapter.RowUpdated +=new SqlRowUpdatedEventHandler(mySqlDataAdapter_RowUpdated);
int ttmy=mySqlDataAdapter.Update(myDS,"picfile");
MessageBox.Show(ttmy.ToString());
objTransaction.Commit();
myCon.Close();
}
even the rowUpdating event is not active , I wrote so much ,but I just lost
;-)