Solved

Exceptions, MS SQL & ODBC

Posted on 1997-09-16
3
238 Views
Last Modified: 2010-04-04
When I add a record which invalidates referential integrity to a MS SQL database (using ODBC) in code I recieve no exception, however when I enter the same data using a visual component I recieve the exception - how can I get the exception to be generated by my code?
0
Comment
Question by:zac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:joseramos
ID: 1345081
I don't know if I understood the question ... but you may try wrapping your code within a try/except block:

        try
           { ... your code that invalidates referential integrity }
        except
            raise;     { or however you want to handle it }
        end;
0
 
LVL 1

Author Comment

by:zac
ID: 1345082
The problem is that although an exception should be generated by the code, it is not!

I have found a work-arround which is to use queries, however I would be interested in finding out the reason for this strange behaviour.
0
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 100 total points
ID: 1345083
Zac,

Set up a Trigger on your table for the Update / Insert / Delete action using SQL Enterprise Manager that examines the data BEFORE it is commited to the table and have the trigger a RAISEERROR statement which WILL be caught by Delphi so that you can handle it in a Try/Except/Finally Block.

Hope this helps.
Pegasus
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question