Solved

Exceptions, MS SQL & ODBC

Posted on 1997-09-16
3
228 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now