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

Catch MS SQL errors using ASP and display custom page...

Status
Not open for further replies.

skurpyun

Programmer
Jun 19, 2002
60
US
Hey all,

I am using asp to code a page and process a page that inserts data into an MSSQL database. While I have done everything (everything as far as validating form inputs) to prevent the database from throwing errors when using the insert command. Yet, I am still concerned about the database throwing errors (and in some cases giving away tables names and/or database structure in the process). So here's the question: Is it possible to catch errors thrown by a database in ASP/VBscript?
Your help is greatly appreciated.

-sk
 
In javascript you use exception handling with try{}catch{} blocks. I think in VB you use ON ERROR GOTO ????

Where are all the VB folks? [lol]

-pete
 
On Error Resume Next
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Some Connection String"
objConn.Execute("INSERT INTO bleh (field1) VALUES ('bleh')")
If objConn.Error.Count > 0 Then
For Each objError in objConn.Errors Then
'Do something w/ the error
Response.Write objError.Description
Next
Else
Response.Write SQL took okay
End If
objConn.Close
Set objConn = Nothing
On Error Goto 0
 
palbano and baddos,

thanks for both your posts. Baddos, you've pretty much hit the jackpot with your post. while i'm still re-doing some code to incorporate it and test it out, logically it seems to be how this is done and i did come across similar code construct in an old VB book i've found. thanks.

-skurpyun
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top