Board index » delphi » exception

exception

Hi, somebody knows, how i get the except on this case

add(' select * from table')
open
if the table not exists the database (SQL-SERVER) give me a error.

How i get this error.

Thanks in advance.

 

Re:exception


"delphi" <newsgroups.borland.com> schrieb im Newsbeitrag
news:3b6195a2_1@dnews...

Quote
> Hi, somebody knows, how i get the except on this case

> add(' select * from table')
> open
> if the table not exists the database (SQL-SERVER) give me a error.

> How i get this error.

try
  Query.Open;
except
  // do some errorhandling here
end;

Thilo Lardon

Re:exception


Hi, i try to use that code, but not work!

The code never intercept the exception before the database show me a
message.

That is the code.

with query1,sql do
 begin
   try
    begin
     close;
     clear;
     add(' select * from teluf ');
     open;
    end
   except
     on E:EDatabaseError do
      begin
         showmessage('error');
      end
   end;

Thanks.

"Thilo Lardon" <lar...@lardon.de> escreveu na mensagem
news:3b629f07_1@dnews...

Quote

> "delphi" <newsgroups.borland.com> schrieb im Newsbeitrag
> news:3b6195a2_1@dnews...
> > Hi, somebody knows, how i get the except on this case

> > add(' select * from table')
> > open
> > if the table not exists the database (SQL-SERVER) give me a error.

> > How i get this error.

> try
>   Query.Open;
> except
>   // do some errorhandling here
> end;

> Thilo Lardon

Re:exception


begin
  SQLQuery1.Close;
  SQLQuery1.SQL.Clear;
  try
    SQLQuery1.Open;
  except
    on E: EDatabaseError do begin
       ShowMessage(E.Message);
  else
     raise;
  end;
end;

//  if you have a system level exception system like exceptional magic try

begin
  SQLQuery1.Close;
  SQLQuery1.SQL.Clear;
  try
    SQLQuery1.Open;
  except
    on E: EDatabaseError do begin
       E.Message := 'My Message for helping find the bug' + #13#10 + E.Message;
       raise;
  else
     raise;
  end;
end;

//  You can also add your on transaction object

var
  aTransDesc: TTransactionDesc;
begin
  SQLQuery1.Close;
  SQLQuery1.SQL.Clear;
  aTransDesc.TransactionID := 1;
  aTransDesc.GlobalID := 0;
  aTransDesc.IsolationLevel := xilREADCOMMITTED;
  try
    SQLConnection1.StartTransaction(aTransDesc);
    SQLQuery1.Open;
    SQLConnection1.Commit(aTransDesc);
  except
    on E: EDatabaseError do begin
       SQLConnection1.Rollback(aTransDesc);
       E.Message := 'My Message for helping find the bug' + #13#10 + E.Message;
       raise;
  else
     SQLConnection1.Rollback(aTransDesc);
     raise;
  end;
end;

--
Thomas Miller
Delphi Client/Server Certified Developer
BSS Accounting & Distribution Software
BSS Enterprise Accounting FrameWork

http://www.bss-software.com

Re:exception


thanks for help.

"tmiller" <tmil...@bss-software.com> escreveu na mensagem
news:3B62FBD2.9BBC128@bss-software.com...

Quote
> begin
>   SQLQuery1.Close;
>   SQLQuery1.SQL.Clear;
>   try
>     SQLQuery1.Open;
>   except
>     on E: EDatabaseError do begin
>        ShowMessage(E.Message);
>   else
>      raise;
>   end;
> end;

> //  if you have a system level exception system like exceptional magic try

> begin
>   SQLQuery1.Close;
>   SQLQuery1.SQL.Clear;
>   try
>     SQLQuery1.Open;
>   except
>     on E: EDatabaseError do begin
>        E.Message := 'My Message for helping find the bug' + #13#10 +
E.Message;
>        raise;
>   else
>      raise;
>   end;
> end;

> //  You can also add your on transaction object

> var
>   aTransDesc: TTransactionDesc;
> begin
>   SQLQuery1.Close;
>   SQLQuery1.SQL.Clear;
>   aTransDesc.TransactionID := 1;
>   aTransDesc.GlobalID := 0;
>   aTransDesc.IsolationLevel := xilREADCOMMITTED;
>   try
>     SQLConnection1.StartTransaction(aTransDesc);
>     SQLQuery1.Open;
>     SQLConnection1.Commit(aTransDesc);
>   except
>     on E: EDatabaseError do begin
>        SQLConnection1.Rollback(aTransDesc);
>        E.Message := 'My Message for helping find the bug' + #13#10 +
E.Message;
>        raise;
>   else
>      SQLConnection1.Rollback(aTransDesc);
>      raise;
>   end;
> end;

> --
> Thomas Miller
> Delphi Client/Server Certified Developer
> BSS Accounting & Distribution Software
> BSS Enterprise Accounting FrameWork

> http://www.bss-software.com

Other Threads