trying to get a friendly error message from a SQL 2000 constraint



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


.



Relevant Pages

  • Re: A real world example
    ... If a constraint is defined in terms of successive states of a database, ... Yes, that's all facts are, though constraints mean that your facts are ... value of a candidate key determines the values of all other attributes, ... The frame of reference for a candidate key is a ...
    (comp.databases.theory)
  • Re: A real world example
    ... If a constraint is defined in terms of successive states of a database, ... facts cannot be thought of just in terms of instances of predicates. ... Yes, that's all facts are, though constraints mean that your facts are ...
    (comp.databases.theory)
  • Re: A real world example
    ... If a constraint is defined in terms of successive states of a database, ... Yes, that's all facts are, though constraints mean that your facts are ... model already allows surrogate keys. ...
    (comp.databases.theory)
  • Re: A real world example
    ... If a constraint is defined in terms of successive states of a database, ... facts cannot be thought of just in terms of instances of predicates. ... Yes, that's all facts are, though constraints mean that your facts are ... referencing all of the attribute values, nor, given only the key value, ...
    (comp.databases.theory)
  • Re: Declarative constraints in practical terms
    ... It is a portion of one or more software applications, ... The definition of a database should be all that is required to ... Constraints are an integral ... declarative constraints: SQL declarations enforced by a DBMS engine ...
    (comp.databases.theory)