Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constraint VIOLATION? ERROR 515

Status
Not open for further replies.

dmerm

MIS
Jul 17, 2000
5
GR
Hi to all,
I want to find a way to get on runtime which constraint is activated. Suppose i want to insert some values into a table which doesn't allow nulls. I want to know which contraint(on which field) is activated and if this is written somewhere on the system tables in the MS SQL Server? I can use all the help i can get.
Thank you,
Dimitris
[sig][/sig]
 
Dimitris, you might be able to retrieve this information from whatever client application you are using. For example, using Visual FoxPro I can call the MESSAGE() function to retrieve the text of the error. Generally, these are passed to VFP from the ODBC interface.

You may or may not have that capability from your client development system. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Hi Robert, I have already try this. I am using VB as the client and i am connecting to SQL Server using ADO. Yes it is true somewhere inside the collections and properties of ADO i can find the error during constraint violation but with a different error code than SQL Server. When it comes to PK constraint violation things aren't the same. Because SQL Server is displaying the error message as soon as you try to cause the violation of one of its constrains i was expecting that this is an information i can get somewhere from the system tables, in order to have only one procedure of checking the constraints no matter what is the actual application i am building. Something similar to the &quot;inserted&quot; table when you process an insert statement. Anyway thank you very much for your advise.
[sig][/sig]
 
About the only other thing I could suggest is querying @@ERROR, but that won't give you everything you need. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Hi Robert, unfortunatelly i have already look the @@error. I will use ADO collection to do this job. Thank you anyway. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top