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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referential Integrity won't allow delete

Status
Not open for further replies.

Rich25

Programmer
Feb 2, 2001
15
0
0
US
In my application, I have a section for topics, which can have can have subtopics. In the admin section, topics cannot be deleted if they still have subtopics because of referential integrity. I'm having trouble figuring out how to just show the user some kind of message telling them that they cannot delete this topic because it still has subtopics. Can someone give me suggestions.

Thanks

Rich
 
find the error number, and then check for it like this:

'Turn error trapping off
on error resume next

'Execute the statement in question
con.execute sqlStatement

'Do your own customized error checking
if err.number <> 0 then
if err.number = theOneYoureLookingFor then
response.write(&quot;There are still subtopics associated.&quot;)
else
response.write(&quot;There was some other error.&quot;)
end if
err.clear
end if

'Turn error trapping back on
on error goto 0


---------------
If you don't know what err.number you're looking for, simply do the same rigamarole as above, but instead of the:

if err.number <> 0 then
if err.number = theOneYoureLookingFor then
response.write(&quot;There are still subtopics associated.&quot;)
else
response.write(&quot;There was some other error.&quot;)
end if
err.clear
end if


make it:
if err.number <> 0 then
response.write(&quot;The error Number is: &quot; & err.number
err.clear
response.end
end if

for the first run of one that you know will throw the error you're looking for. The specific error number will write to the screen, and then you can start trapping that error and providing your own special message.

good luck! :)
Paul Prewett

ps. This method can be adapted for customized trapping of all errors -- which your users will appreciate you spending the time to do.
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top