SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: Error Handling

  1. #1
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error Handling

    How can I trap this kind of error?

    HTML Code:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    
    [MySQL][ODBC 5.1 Driver][mysqld-5.5.17]Duplicate entry '1218-1-1' for key 'PRIMARY'
    
    /ticksys/data/insertcb.asp, line 17
    With this code?I don't know if I did it right.

    HTML Code:
    <%
    On Error Resume Next
    If Err.Number > 0 Then
    %>
    <%   
        Response.Write("Error Number -> " & Err.Number)
        Response.write("<BR>Error Source -> " & Err.Source)
        Response.Write("<BR>Error Desc   -> " & Err.Description)
        Err.Clear
    %>
    
    <%
    
        Else
        Response.redirect("editcb.asp?refID="&Request.Form("tnum")&"")
       
        End If
        Conn.Close()  
        Set exec = Nothing  
     %>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to specify the "On Error Resume Next" line before your db execute statement.

  3. #3
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how?can you give me a sample?

  4. #4
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i got it now .thanks Mr. Flakes.

  5. #5
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    357
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Remember on error resume next will remain on for the remainder of the page unless you turn it back off with on error goto 0. Also you have to test the err variable immediately after the statement you suspect may fail. The asp error is reset each statement line and if an earlier line caused an error but you test later you will not see the first error correctly.

    Classic asp error trapping is pretty much a joke in most cases.
    Doug G
    =====
    "If you ain't the lead dog, the view is always the same - Anon

  6. #6
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tnx sir

  7. #7
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,830
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    @joeyramirez

    How can I trap this kind of error?

    HTML Code:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [MySQL][ODBC 5.1 Driver][mysqld-5.5.17]Duplicate entry '1218-1-1' for key 'PRIMARY'

    /ticksys/data/insertcb.asp, line 17
    The MySQL error occurs because you are trying to insert a Primary Key Value that already exists.

    Please show the MySQL Script which I am sure can be modified to eliminate the error.
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014

  8. #8
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dim sql,exec
    sql=""
    sql=sql &"INSERT INTO tblselectedprob (Ticket,cat,value) VALUES ('"&Request.Form("tnum")&"','"&Request.Form("concern")&"','"&Request.Form("problem")&"') "
    Set exec=Conn.Execute(sql)

  9. #9
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,830
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    @joeyramirez can you:

    1. ECHO your SQL statement
    2. supply tablename primary keys
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014

  10. #10
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    357
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Not really on topic, but you really shouldn't pass unfiltered request.form data directly to your database or you too may become a victim of sql injection attacks.
    Doug G
    =====
    "If you ain't the lead dog, the view is always the same - Anon

  11. #11
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,830
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by John_Betong View Post
    @joeyramirez can you:

    1. ECHO your SQL statement
    2. supply tablename primary keys
    Can you also check to make sure you have auto-increment set for the Primary Key
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014


Bookmarks

Posting Permissions

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