lboeldt
Posts: 53
|
| Posted: 01/31/2007, 10:14 AM |
|
Hi I've read several posts asking for the same thing so I'll respond here.
SQL Errors do not transcend the class hierarchy so you have to get the from the connection object. I added this code to the after execute event of a grid and record form in order to replace the "UNIQUE KEY" error message that comes up with something more friendly.
Here's how I replaced the ugly "UNIQUE KEY" error with something different.
<pre>
dim str
' Grab the error string
' ToString is not found in the docs, but if you look at the code
' for clsErrors (classes.asp) you'll find it defined as public
str = myEGrid.datasource.connection.errors.ToString()
' Now look for an instance of the phrase "UNIQUE KEY"
if instr(1, str, "UNIQUE KEY", 1) > 0 then
' Yup, found one, clear the error object for the grid and add your own.
myEGrid.datasource.connection.errors.clear
myEGrid.errors.clear
myEGrid.errors.adderror "Sorry, you can only add one of each unique identifier."
end if
<pre>
|
lboeldt
Posts: 53
|
| Posted: 01/31/2007, 10:16 AM |
|
Sorry nuB post. Here's the code in a wrapper...
dim str
' Grab the error string
' ToString is not found in the docs, but if you look at the code
' for clsErrors (classes.asp) you'll find it defined as public
str = myEGrid.datasource.connection.errors.ToString()
' Now look for an instance of the phrase "UNIQUE KEY"
if instr(1, str, "UNIQUE KEY", 1) > 0 then
' Yup, found one, clear the error object for the grid and add your own.
myEGrid.datasource.connection.errors.clear
myEGrid.errors.clear
myEGrid.errors.adderror "Sorry, you can only add one of each unique identifier."
end if
|