View Full Version : error handling
04-28-2007, 09:03 PM
I have an error handling procedure which writes the err.number and err.description but now when i'm testing it keeps telling me the error is on line 0 ( where there is a query that is not good but I can't find it)
anyway of knowing exactly which procedure is returning the error?
04-30-2007, 03:33 PM
From my code...and I usually do see the actual sql syntax error.
Response.Write "<p>Error Description: " & " '" & Err.Description & "'</p>"
Response.Write "<p>Error Number: " & " '" & Err.Number & "'</p>"
Response.Write "<p>Error Source: " & " '" & Err.Source & "'</p>"
04-30-2007, 03:41 PM
it still keeps telling me error at line 0
any idea how to debug if it tells me error at line 0 - why wouldn't it give me a line number?
04-30-2007, 09:04 PM
Got more code?
04-30-2007, 09:05 PM
Oh, the line number will be 0 if the error is the query. Post your query, too. ASP just passes the query to the database driver, it isn't running the query. It can only report back what the DB tells it. As far as the ASP code is concerned, the error occurred on the line where the query was run. You won't get more than that from ASP.
05-05-2007, 01:32 AM
Line 0 also flags up for syntax errors rather than runtime errors.
Are you definately using On Error Resume Next or are you on On Error Goto 0 (default)
05-11-2007, 03:11 PM
In your code, try setting the SQL query to a variable. Then use your recordset to open the variable.
Then you get the line number AND you get to see where your query went wrong.
Set rs = Server.CreateObject("ADODB.Recordset")
Set Conn = Server.CreateObject("ADODB.Connection")
x = "try me" 'for testing
strSQL = "SELECT * FROM table WHERE x=" & x
schtopp 'as long as On Error Resume Next <> on, then your ASP will stop here...
rs.open strSQL, conn
'do more stuff
NOTE: The above will give you an error because variable "x" is text, and the SQL string is without single quotes.
Just another method of gaining insight into your errors.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.