Re: TADOQuery Error Handling
- From: Brian Bushay TeamB <BBushay@xxxxxxxxx>
- Date: Thu, 21 Sep 2006 20:55:29 -0500
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
.
- References:
- TADOQuery Error Handling
- From: PK
- TADOQuery Error Handling
- Prev by Date: Re: Delphi 6 - ADO - MS SQL Server
- Next by Date: ADO - ClientDataSet - Master/Detail
- Previous by thread: TADOQuery Error Handling
- Next by thread: ADO - ClientDataSet - Master/Detail
- Index(es):
Relevant Pages
|