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
- void __fastcall TfMenus::btnDeleteClick(TObject *Sender)
- {
- char dbCommandLine[1000];
- strcpy(dbCommandLine, "delete from ITGenSysMenus where IDMenu = ");
- strcat(dbCommandLine, DMAdminTasks->QSysMenusIDMenu->Text.c_str());
- DMAdminTasks->QAdminTasks->Active = false;
- DMAdminTasks->QAdminTasks->SQL->Clear();
- try
- {
- DMAdminTasks->QAdminTasks->SQL->Add(dbCommandLine);
- }
- catch(int a)
- {
- char exceptionmsg[100], temp[10];
- strcpy(exceptionmsg, "Caught exception number: ");
- sprintf(temp, "%d", a);
- strcat(exceptionmsg, temp);
- Application->MessageBoxA(exceptionmsg, "Teste", MB_OK);
- }
- DMAdminTasks->QSysMenus->Active = false;
- DMAdminTasks->QSysMenus->Active = true;
- }