Re: TADOQuery Error Handling



I have an application that allows users to generate a query which is then
executed to return data to a grid on an application form. All works well
unless SQL statement generates an error (i.e. syntax, etc) which causes the
application to fail. I have attempted to trap this error with Try...Except
on ADOQuery.Open, ADOQuery.Active, ADOQuery.ExecSQL and have not been able
to trap the error successfully. If anyone could direct me to a resource
that describes or provides an example of an approach to trap these errors I
would appreciate the assistance. Thanks.

What database are you using?

This code should trigger and error if the SQL does not execute

With AdoDataset1 do Begin
Close;// make sure dataset is closed

// Set commandText here to your user SQL

Try
Open ; //This will execute the SQL
Except
Raise; //raise the error generated by improper SQL statement
// or put your won error handling here
End;//try



end;
--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx
.



Relevant Pages

  • Re: Fieldcount is not right.
    ... What is this part of your SQL statment? ... > The following sql statement is used to fill a datareader ... > There are 6 fields requested from the database and when I execute this sql ... the one in column CarrierSiteName in the sql statement. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Adding Images To MySQL
    ... you need the SQL text inside a string:: ... and you can execute it with:: ... That would be OK when you create the database for the first time. ... Note that execute has two arguments: first, a string with the sql statement text; second, a tuple containing the values. ...
    (comp.lang.python)
  • Re: Opinions on approach, please...
    ... Create a data layer program per table, ... number of bind variable tokens in your dynamic SQL. ... then simply EXECUTE that without passing it any parameters? ... Hard code WHERE clauses. ...
    (comp.lang.cobol)
  • Re: Cascading Updates not working
    ... I'd love to have a tool that would generate and execute scripts for creating ... other SQL DBMS-related newsgroups, is to post SQL DLL statements (e.g. ... SQL statement at a time i.e. even if you gave someone a script there is ...
    (microsoft.public.access.tablesdbdesign)
  • Re: SQL Injection- Bypassing magic_quotes
    ... Because i was trying to execute: ... Don't terminate the query and you most ... Or try something like bobcat or one of the other SQL injection tools out ... Chief Information Security Officer ...
    (Pen-Test)