Delphi Error Trap For Failed Stored Procedure

Posted on 2014-04-04
Last Modified: 2014-04-16
I have a Delphi 2006 application which calls several ADO Stored Procedures.
My problem is that the SP returns a Transaction Deadlock every now and then and If have implemented the standard Delphi error trapping but it does not seem to work ?

Is there another way of catching these errors so my application does not crash ?

        Memo1.Text:=Memo1.Text+'Start Recalc'+FormatDateTime('HH:MM:ss',Time)+#13+#10;
        while Brk=1 do
           except on E:Exception do
                Memo1.Text:=Memo1.Text+'ADOCan Error';

        Memo1.Text:=Memo1.Text+'End Recalc'+FormatDateTime('HH:MM:ss',Time)+#13+#10;


Question by:Hornwood
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39977679
why this?

LVL 27

Expert Comment

by:Sinisa Vuk
ID: 39977861
I suggest to use:
    DBConn.CommitTrans; //on success, commit the changes;
    DBConn.RollbackTrans; //on failure, undo the changes;

Open in new window

DBConn is AdoConnection, and your ADOCAN is linked to it.

... your procedure can be called using TADOCommand component too:
q: TADOCommand;
    q.CommandText:='exec procName param1, prarm2';

Open in new window

LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39977922
Your while loop does not make any sense. The wrapped code will just run once, so what is the point of the while loop?

I would have written that block of code as follows (note the e.message I added):
  Memo1.lines.add('Start Recalc '+FormatDateTime('HH:MM:ss',Time));
  Memo1.lines.add('End Recalc '+FormatDateTime('HH:MM:ss',Time));
except on E:Exception 
  do Memo1.lines.add('ADOCan Error: ' + e.message);      

Open in new window

can you elaborate on "...implemented the standard Delphi error trapping but it does not seem to work"? What is not working as expected? What error are you getting?
LVL 38

Accepted Solution

Geert Gruwez earned 500 total points
ID: 39979957
you will never be able to solve the deadlock from the delphi app
you need to look at the stored procedure

somewhere you are locking row A, someone else is locking row B
then someone else wants to lock row A and then you want to lock row B
that's your deadlock

find what 2 rows you are locking, and then see if anyone can do it in the reverse order

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month6 days, 11 hours left to enroll

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question