Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 781521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:14:34+00:00 2026-05-14T20:14:34+00:00

I have a TClientDataSet connected to a TDataSetProvider, which in turn is connected to

  • 0

I have a TClientDataSet connected to a TDataSetProvider, which in turn is connected to a TAdsQuery. I set the SQL command and then open the ClientDataset something like this:

try
  CDS.CommandText := 'SELECT * FROM tablename WHERE fieldname = 1';
  CDS.Open
except
  // trap exception here - this never gets executed!
end;

If the SQL statement in CommandText fails, however (syntax error or whatever) I get an exception within the Advantage code, but it never gets caught in my own exception handling code.

Is there any way for me to trap this error and report it nicely to the user. Alternatively is there a way to verify the syntax of an SQL query before executing it?

I’m using Delphi Pro 2009, and Advantage Local Server 9.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:14:35+00:00Added an answer on May 14, 2026 at 8:14 pm

    Advantage includes a EADSDatabaseError which will provide more information about the exception that was raised.

    try
      CDS.CommandText := 'SELECT * FROM tablename WHERE fieldname = 1';
      CDS.Open
    except
    on E: EDatabaseError do
    begin
      if ( E is EADSDatabaseError ) then
      begin
        ErrorString := (E as EADSDatabaseError).SQLErrorCode + E.Message;
        application.messagebox ( pchar(ErrorString), 'Advantage Database Error', 0 )
      end
      else
        application.messagebox (pchar(E.message), 'Native Database Error', 0 );
      end;
    end;
    

    You can check the syntax of the SQL statement before executing it by using the VerifySQL method of the TAdsQuery component. This will raise an EADSDatabaseError exception if the SQL syntax is incorrect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DBGrid which is connected to a ClientDataSet and it has a
I have a DBGrid which is connected to a ClientDataSet and it has a
In my form I have TADOQuery,TDataSetProvider,TClientDataSet,TDataSource,TDBGrid linked. AdoQuery use SQL Server view to query
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have an application in Delphi 7 which is using a clientdataset, and make
I have a DataSnap server that creates a TSQLQuery, TDataSetProvider and a TClientDataSet that
The scenarios is like this: We have some SQL table. We are performing an
I have a TClientDataset which could contain column names with non-ascii characters. It seems
I have the following DBX structure in my software: TSQLDataSet -> TDataSetProvider -> TClientDataSet
I have a TClientDataset that is managed in Thread 1. In a different thread

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.