Solved

Exceptions, MS SQL & ODBC

Posted on 1997-09-16
3
235 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
proper way to parse text with delphi 7 120
add combobox item based on numbers 9 141
Comparing dates in Delphi. Greater than/ Less than 3 150
update joined tables 2 45
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

775 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