473,320 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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,

Fabiano.

Here is a portion of the code:
Expand|Select|Wrap|Line Numbers
  1. void __fastcall TfMenus::btnDeleteClick(TObject *Sender)
  2. {
  3.  char dbCommandLine[1000];
  4.  
  5.  strcpy(dbCommandLine, "delete from ITGenSysMenus where IDMenu = ");
  6.  strcat(dbCommandLine, DMAdminTasks->QSysMenusIDMenu->Text.c_str());
  7.  
  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.   }
  22.  
  23.  DMAdminTasks->QSysMenus->Active = false;
  24.  DMAdminTasks->QSysMenus->Active = true;
  25. }
  26.  
Mar 15 '07 #1
1 3356
Ganon11
3,652 Expert 2GB
Does the Add() function throw an int, or does it throw an Exception (or some other class/type)?
Mar 15 '07 #2

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

Similar topics

4
by: Ele | last post by:
When Exception handling disabled compiler still spits out "C++ exception handler used." Why is that? Why does it ask for "Specify /EHsc"? Thanks! c:\Program Files\Microsoft Visual Studio...
2
by: Adrian Burka | last post by:
HELP! I have written a web service, and a program in C# using Microsoft Visual C#.NET to interact with the web service. Exception handling isn't working in my application, though. One function...
1
by: Reuben | last post by:
Hi, I've installed Visual C# Express 2005 onto 2 computers: one which already had Visual Studio .NET 2003 installed on it, and another that was a clean installation of Windows (both are Xp Pro)....
6
by: Robin Riley | last post by:
Hi, I have a .NET solution that contains a dll project and a tester application project which, of course, invokes the dll. The dll project has exception handling in it. What's happening is that...
41
by: Zytan | last post by:
Ok something simple like int.Parse(string) can throw these exceptions: ArgumentNullException, FormatException, OverflowException I don't want my program to just crash on an exception, so I must...
1
by: JRC903 | last post by:
Dear Folks: I am current working on a project involving trying to find the cause of some erratic behavior in an old Borland C++ 4.5 database application. Prehaps for obvious reason the orginal...
0
by: =?Utf-8?B?UG9sbHkgQW5uYQ==?= | last post by:
Hi, I have previously used EL v 3.1 Exception Handling application block successfully. I thought I would now try to do the same with EL v 4.0. My first experiment was to replace an exception....
0
by: srizzler | last post by:
Hi All: I am trying to implement Exception Handling using Enterprise Library 3.1's Exception Handling Application Block as well as Logging Blocks. I have a windows application developed in...
7
by: Muzammil | last post by:
Hi, i m unable to make a programable exception handling. i can just throw an exception and catch it and try for ones. but its not enough, i want to an exception which can work untill user dont...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.