I've been using MyDAC for Borland Builder 6 for a while now, but I've just started a new project which uses elements I've never used before in any form - namely transactions.
I'd like a little help to get me started please.
The following is some basic test code:
Code: Select all
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
if (!MyConnection1->InTransaction)
{
MyConnection1->StartTransaction();
MyQuery1->SQL->Text = "SELECT * FROM cvbs c;";
MyQuery1->Execute();
MyConnection1->Commit();
}
}
The following is from the Borland help files:
Code: Select all
void __fastcall TForm1::TransferButtonClick(TObject *Sender)
{
if (!SQLConnection1->InTransaction)
{
TTransactionDesc TD;
TD.TransactionID = 1;
TD.IsolationLevel = xilREADCOMMITTED;
SQLConnection1->StartTransaction(TD);
try
{
int Amt = StrToInt(AmtEdit->Text);
Debit->Params->ParamValues["Amount"] = Amt;
Credit->Params->ParamValues["Amount"] = Amt;
SQLConnection1->Commit(TD); // on success, commit the changes;
}
catch (...)
{
SQLConnection1->Rollback(TD); // on failure, undo the changes
ShowMessage("Transfer failed")
}
}
}
Code: Select all
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
if (!MyConnection1->InTransaction)
{
TTransactionDesc TD;
TD.TransactionID = 1;
TD.IsolationLevel = xilREADCOMMITTED;
MyConnection1->StartTransaction(TD);
MyQuery1->SQL->Text = "SELECT * FROM cvbs c;";
MyQuery1->Execute(); // this line required?
MyConnection1->Commit(TD);
}
}
If anyone can point me in the direction of a Borland based tutorial for DB transaction handlers I would very much appreciate it.
Many thanks in advance.