Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: error handling

  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts

    error handling

    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?

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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>"

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Got more code?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #6
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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)

  • #7
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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.

    Code:
    <%
    Set rs = Server.CreateObject("ADODB.Recordset")
    Set Conn = Server.CreateObject("ADODB.Connection")
    '
    Conn.Open "DSN=yourConnectionString"
    '
    x = "try me"			'for testing
    '
    strSQL = "SELECT * FROM table WHERE x=" & x
    '
    response.write strSQL
    response.flush
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •