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

  • Home
  • SEARCH
  • 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 7805089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:06:41+00:00 2026-06-02T02:06:41+00:00

I am having a Database connected application. Connected using BDE components and database is

  • 0

I am having a Database connected application.
Connected using BDE components and database is MySQL.

Now I am doing some validations for checking if duplicate entry while insert statement is executed.

The following is the code to check if duplicate entry for primary key attribute .

var
  error :string; 
  cmpres:integer;
begin
 ...
 /* all my data queries */
  try
    Query1.ExecSQL;
  Except
   on E: Exception do
   /*check if its a Duplicate entry or other exception*/
    begin    
         error := E.Message;
         error := copy(error,length(error)-16,length(error)-2);
         cmpres :=CompareStr(LowerCase(error),'for key '+#39+'primary'+#39) ;
         if cmpres = 0  then
           MessageDlg('Entry already exist',mtError,[mbok],0)
         else
           MessageDlg('Invalid Data Entries',mtError,[mbok],0);
         exit;
    end;
  end;
end; 

The database exceptions are broadly put inside EDatabaseError

Can anyone tell me is there any way I can differentiate between these errors without doing the Message comparisons.
Thanks in advance

  • 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-06-02T02:06:43+00:00Added an answer on June 2, 2026 at 2:06 am

    If you’re using BDE, the exceptions should be EDBEngineError, not EDatabaseError. You can do this:

    try
        Query1.ExecSQL;
    except
        on E: EDBEngineError do
        begin
            for i := 0 to E.ErrorCount - 1 do
            begin
                err := E.Errors[i];
                case err.ErrorCode of
                    ... stuff ...
                end;
            end
        end;
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having some trouble with an oracle database. Every time i try to connect,
I am having trouble UPDATING my database using FMDB . Here's my SQL BOOL
Am having a combobox which has its data populated from a SQL database, using
I have a table in database that is having some fields one of which
I have a web application that relies on a MySQL database, for which I
Just started using CodeIgniter, loving it. Having enabled the database to be one of
Unable to connect to your database server using the provided settings. I've been having
i am creating a csv by using INTO OUTFILE statement for a mysql database.
I am creating a C++ application the uses a MySQL database. I would like
I am having a VB.Net application. I connect it with a MS Access database.

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.