By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,171 Members | 1,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,171 IT Pros & Developers. It's quick & easy.

Borland Visual C++ / ADO / SQL / Exception Handling

P: 5
Hi there!

Here is the scenario:
I'm currently working on a project under Borland Visual C++ IDE.
I have no issues on working with ADO and SQL.
I can connect to the database, make queries, execute SQL code, etc.
One of those queries should perform a delete action from a table in the database and that is also working fine.
The problem is that I wanted to add some customized message to end-user when he tries to delete a row from that table and the operation will not succeed due to database relational issues.

I've tried using try...catch, but that doesn't seem to work, once it won't display any errors, but won't also display the customized message too.

Thanks in advance for any help provided.

Kind regards,


Here is a portion of the code:
Expand|Select|Wrap|Line Numbers
  1. void __fastcall TfMenus::btnDeleteClick(TObject *Sender)
  2. {
  3.  char dbCommandLine[1000];
  5.  strcpy(dbCommandLine, "delete from ITGenSysMenus where IDMenu = ");
  6.  strcat(dbCommandLine, DMAdminTasks->QSysMenusIDMenu->Text.c_str());
  8.  DMAdminTasks->QAdminTasks->Active = false;
  9.  DMAdminTasks->QAdminTasks->SQL->Clear();
  10.   try
  11.   {
  12.    DMAdminTasks->QAdminTasks->SQL->Add(dbCommandLine);
  13.   }
  14.   catch(int a)
  15.   {
  16.    char exceptionmsg[100], temp[10];
  17.    strcpy(exceptionmsg, "Caught exception number:  ");
  18.    sprintf(temp, "%d", a);
  19.    strcat(exceptionmsg, temp);
  20.     Application->MessageBoxA(exceptionmsg, "Teste", MB_OK);
  21.   }
  23.  DMAdminTasks->QSysMenus->Active = false;
  24.  DMAdminTasks->QSysMenus->Active = true;
  25. }
Mar 15 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,652
Does the Add() function throw an int, or does it throw an Exception (or some other class/type)?
Mar 15 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.