Exception logic no longer works 
Author Message
 Exception logic no longer works

The following logic used to catch an invalid non select SQL statement
in delphi 2.0. In Delphi 2.11, or whatever the latest version is for
2.0 the error isn't caught and the program hangs.  It's executing a thread.
Any clues as what I am doing wrong?

Thanks

        try
           if tdb = nil then
              Form1.Database1.StartTransaction
           else
              tdb.StartTransaction;
           ExecSql;
           if tdb = nil then
              Form1.Database1.Commit
           else
              tdb.Commit;
        except
           on E:EDatabaseError do
           begin
              if tdb = nil then
                 Form1.Database1.Rollback
              else
                  tdb.Rollback;
              emsg := Copy(E.Message, 1, POS('[',E.Message) - 2);
              Synchronize(DisplayEMsg);
           end;
        end;



Wed, 18 Jun 1902 08:00:00 GMT  
 Exception logic no longer works

Quote:

> The following logic used to catch an invalid non select SQL statement
> in Delphi 2.0. In Delphi 2.11, or whatever the latest version is for
> 2.0 the error isn't caught and the program hangs.  It's executing a
> thread. Any clues as what I am doing wrong?

Hello,
I had a similar kind of a problem (ODBC, no threads involved), and I
think it was caused by BDE. After update from Delphi 2.00 to
Delphi 2.01, my application stopped working properly. I experimented
quickly with different BDE versions. I compiled my application only
once, with Delphi 2.01, and used that .EXE to test three different BDE
versions:

BDE that shipped with Delphi 2.00:
   my application worked OK,
   try...except captured all SQL errors well,

BDE that shipped with Delphi 2.01:
   did not work, an SQL error caused the program to hang immediately,
   and it had to be killed

newer BDE (version 3.5 , I think):
   worked OK.

So, replacing BDE with older or newer version solved my problem.
Hope this helps. Regards, M.Aho

----------------------------------------------------------------------

Quote:
>         try
>            if tdb = nil then
>               Form1.Database1.StartTransaction
>            else
>               tdb.StartTransaction;
>            ExecSql;
>            if tdb = nil then
>               Form1.Database1.Commit
>            else
>               tdb.Commit;
>         except
>            on E:EDatabaseError do
>            begin
>               if tdb = nil then
>                  Form1.Database1.Rollback
>               else
>                   tdb.Rollback;
>               emsg := Copy(E.Message, 1, POS('[',E.Message) - 2);
>               Synchronize(DisplayEMsg);
>            end;
>         end;



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help Working with EDBEngineError exception

2. HELP Exception handling doesn't work

3. Keypressed no longer works in Windows for extended characters

4. Readkey no longer works in Windows

5. Must know how long my program has worked

6. Business logic separated from GUI?

7. Logic Question re: SQL

8. Logic Process: DataSentry/SelfCheck

9. Confused by logic - seeking some inspiration

10. random function and logic

11. Question re: Dynamic business logic in database app.

12. Graphical Logic Mapping

 

 
Powered by phpBB® Forum Software