trying to get a friendly error message from a SQL 2000 constraint
- From: "Keith G Hicks" <krh@xxxxxxxxxxx>
- Date: Fri, 29 Apr 2005 21:38:27 -0400
I'm trying to set up a table that will convert default SQL error messages
for check constraints into friendly front end messages (in my
Application.OnException handler). What I'm having trouble with is how to
pick apart the default message so I can do this. Is the error stored
anywhere that I can look at it's parts? Any suggestions on a good strategy
for this sort of thing would be appreciated.
I know how to do that in stored procedures but in Check Constraints, where
is there a code? I created a constriant that prevents zero length strings
on a column in a table as follows:
Len(LTrim(RTrim(CustName))) > 0
And the message that is returned is:
Database error: '[Microsoft][ODBC SQL Server Driver][SQL Server]UPDATE
statement conflicted with COLUMN CHECK constraint
'CK_tblCustomers_CustName'. The conflict occurred in database 'WidgetsInc',
table 'tblCustomers', column 'CustName'. [Microsoft][ODBC SQL Server
Driveer][SQL Server]The statement has been terminated.'
If I can always be guaranteed that the message will start with "Database
error: '[Microsoft][ODBC SQL Server Driver][SQL Server]" and end with
"[Microsoft][ODBC SQL Server Driveer][SQL Server]The statement has been
terminated.'" then I suuppose I can parse it out. But I was hoping there
would be an easier way to do it.
Thanks,
Keith
.
- Prev by Date: Re: stored proc RETURN_VALUE.... there it is, I want to use it !!!
- Next by Date: Re: stored proc RETURN_VALUE.... there it is, I want to use it !!!
- Previous by thread: TAdoQuery not closing the connection ?
- Next by thread: Storing and displaying pictures with MS Access -D7
- Index(es):
Relevant Pages
|