Results 1 to 5 of 5

Thread: Trap SQL Error - asp-db enterprise

  1. #1
    Join Date
    Nov 2002
    Posts
    8

    Trap SQL Error - asp-db enterprise

    I have a aspdb grid with editing. The sql table it goes against has an index preventing duplicate values. It comes back with a ugly error when this happens. I want to trap this error and replace it with a nice message but I'm not sure how.

    Thanks
    jb

  2. #2
    Join Date
    Oct 2002
    Posts
    5
    I have the same problem. Have you been able to work up a solution?

  3. #3
    Join Date
    Oct 2002
    Posts
    32
    Here is one way to do it.
    Check for "Records affected" to see if it is equal to ONE. If not, take action.
    This code works:

    <% response.buffer=true %>
    <HTML>
    <HEAD><title> ASP-db: EDIT NWIND EMPLOYEES TABLE </title></HEAD>
    <BODY>
    <%
    MYSELF = Request("PATH_INFO")
    RQ1 = "ASPdbClick_21"
    LASTCLICK = UCASE(Request(RQ1))
    Response.write("LASTCLICK=" & LASTCLICK)

    Set MyDb = Server.CreateObject("ASP.db")
    MyDb.dbUnit = 21
    Mydb.dbDSN = "NWIND"
    MyDb.dbGridTableTag = "Border=2"
    MyDb.dbMode = "Both"
    MyDB.dbDebug = 101
    Mydb.dbNameMap = "EmployeeID,Emp<BR>ID; TitleOfCourtesy,Common<BR>Title; PostalCode,Postal<BR>Code;"
    Mydb.dbButtonAnchor = false

    MyDb.dbEditFlds = "1,2,3,4,5,6,7,8,9,10,11,12,13,15,16" ' not 14 (Photo)
    Mydb.dbEditParams = "TableName=Employees,BookMarkFlds=0,TableTag=Borde r=2,RecordScope=single"

    MyDb.dbSQL = "Select * from Employees"
    MyDb.dbImageDir="../images/"
    Mydb.dbNavigationItem="Next, Prev, Gridrow, Filter, resetFilter, add, update, delete, reload"
    Mydb.dbNavigationIcon="std"

    MyDb.ASPdb

    RECSAFF = Session("SV_RecAffected_21")
    if ((LASTCLICK="APPLYUPDATE" OR LASTCLICK="APPLYADD") AND RECSAFF <> 1) then
    Response.Clear
    Response.write("CHANGE NOT MADE! <BR>")
    Response.write("Be sure that all required fields are filled out properly. <BR>")
    Response.write("<A HREF=" & MYSELF & "> click here to continue </A> <BR>")
    end if
    %>

    </BODY>
    </HTML>

  4. #4
    Join Date
    Nov 2002
    Posts
    8
    There is also a session variable that is set with the error code. Unfortunatly my co-worker who found it is out. I'll post it when he gets in.

  5. #5
    Join Date
    Oct 2002
    Posts
    5
    I think it's SV_ERROR_Unit#

    I added this code after the call to oDB.ASPdb on my page to see all of the session vars.

    x = 1
    for each oItem in session.contents
    Response.write oItem & " = " & session.Contents(x) & "<BR>"
    x = x + 1
    Next

Posting Permissions

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