Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQLDataset multiple CommandText

Status
Not open for further replies.

PeterG30

Programmer
Mar 23, 2009
1
AU
Hello

I need to update a record in the Employee table, and, if that is succesful, create another record in the same table. This follows the lines of the classic bank transaction where one account is debited & the other credited, so I would like to have the ablity to Rollback the transaction if either transaction is unsuccesful.

I dynamically create a TTransactionDesc and a TSQLDataset then process the first update...

TD.IsolationLevel := xilREADCOMMITTED; // default
TD.TransactionID := 1;
aSQLDSet := TSQLDataset.Create(nil);
try
aSQLDSet.SQLConnection := SQLConnection1;
aSQLDSet.SQLConnection.StartTransaction(TD);
aSQLDSet.CommandText := SQLUPDADDR;
aSQLDSet.ParamByName('EMPLOYEEID').AsInteger := iType;
try
aSQLDSet.ExecSQL;
***??
aSQLDSet.SQLConnection.Commit(TD);
except
on E:Exception do
begin
//msgbox about failure
aQLDSet.SQLConnection.RollBack(TD);
end;
end;


...which works great, but I need to repeat the process to INSERT the new row that I need. Can I just put in another CommandText and new params in the line ***??, or is there a better way to do this.

Thanks & TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top