ADO.Net 2.0 Transaction
-
hi the code below throws this exception "ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized." on the update statement in the try catch block. Please help. DatabaseDataSet.PersonnalInfoDataTable ds = new DatabaseDataSet.PersonnalInfoDataTable(); DatabaseDataSetTableAdapters.PersonnalInfoTableAdapter adapter = new Testing.DatabaseDataSetTableAdapters.PersonnalInfoTableAdapter(); adapter.Fill(ds); DatabaseDataSet.PersonnalInfoRow newrow = ds.NewPersonnalInfoRow(); newrow["firstname"] = this.textBoxFirstName.Text; newrow["lastname"] = this.textBoxLastName.Text; newrow["telephone"] = this.textBoxTelephone.Text; ds.AddPersonnalInfoRow(newrow); adapter.Connection.Open(); SqlTransaction myTrans= adapter.Connection.BeginTransaction(); try { adapter.Update(ds); myTrans.Commit(); ds.AcceptChanges(); } catch(Exception l) { myTrans.Rollback(); ds.RejectChanges(); } adapter.Connection.Close();
Nana