error checking doesn't appear to be working

Discussion in 'ASP General' started by Steven Scaife, Aug 13, 2004.

  1. Below is my ASP page, I have changed the update to read DRIAL which doesn't
    exist, shouldnt this throw an error, or if the connection cannot be made
    shouldnt it throw an error as well

    thanks in advance

    <%@language="VBScript"%>
    <% option explicit %>
    <% response.buffer = True %>

    <%
    dim telNo, comp, adbTable
    telNo = request.form("telNo")

    response.write telno & "<BR>"
    comp = inStr(1, telNo, " ", 1)

    if comp <> 0 then
    response.redirect "phone.asp?QS=yes&num=" & telno
    end if
    %>

    <%
    Dim conn, RS, strSQL, strConnImpreza, strConnDom_Con,
    strConnImprezaTouchStar

    'connection details
    <% server.execute ("connections.inc") %>
    'error checking starts here, if an error is encountered display a msg to the
    user and carry on
    on error resume next

    conn.open strConnImpreza

    'this sql statement can be run on both impreza and dom_con tables Amcat'
    strSQL = "INSERT INTO MasterDoNotCall(phonenum) VALUES ('" & telNo & "');"
    conn.execute strSQL 'run the sql statement

    disperror("imprezanocall") 'call the error function

    response.write strSQL & "<BR>"
    conn.close 'close the connection'


    conn.open strConnDom_Con 'open the connection to dom_con'

    strSQL = "INSERT INTO MasterDoNotCall(phonenum) VALUES ('" & telNo & "');"
    conn.execute strSQL

    disperror("DomConNoCall")

    response.write strSQL & "<BR>"
    conn.close


    'for this table we need to run two sql statements, first open the
    connection'
    conn.open strConnImprezaTouchStar
    disperror("connTouchstar")

    strSQL = "INSERT INTO Nevercall (PhoneNum, EffectiveDate) " & _
    "VALUES ('" & telNo & "', Getdate())"
    conn.execute strQSL

    disperror("imprezaTouchstarNC")

    response.write strSQL & "<BR>"

    strSQL = "UPDATE DIAL SET CRC = 'DNC' WHERE PhoneNum = '" & telNo & "';"
    conn.execute strSQL

    disperror("imprezaTouchstar")

    response.write strSQL & "<BR>"


    conn.close
    set conn = nothing


    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Updated Databases</title>
    <style>
    <!--
    body { font-family: arial, helvetica, sans-serif; font-size: 10px; }
    //-->
    </style>
    </head>

    <body>
    Detail have been inserted into the corresponding databases


    </body>
    </html>
    <%
    sub dispErr(adbTable)
    ' if an error is raised then trap it here and end processing
    IF err.number <> 0 then
    %>

    <p>Record already exists on the server and table.</p>
    <%
    SELECT CASE adbTable
    case "imprezanocall" %>
    <p>Server: Impreza, Database: AMcat, Table: MasterDonotcall; Was not
    updated</p>
    <% case "DomConNoCall" %>
    <p>Server: Dom_Call, Database: AMcat, Table: MasterDonotcall; Was not
    updated</p>
    <% case "imprezaTouchstar" %>
    <p>Server: Impreza, Database: Touchstar, Table: Dial; Was not
    updated</p>
    <% case "imprezaTouchstarNC" %>
    <p>Server: Impreza, Database: Touchstar, Table: Nevercall; Was not
    updated</p>
    <% case "connTouchstar" %>
    <p>Connection to Touchstar failed</p>
    <% END SELECT
    end if
    Err.Clear

    end sub
    %>
     
    Steven Scaife, Aug 13, 2004
    #1
    1. Advertising

  2. "Tarwn" <> wrote in message
    news:...
    > "Steven Scaife" wrote:
    > > <%
    > > Dim conn, RS, strSQL, strConnImpreza, strConnDom_Con,
    > > strConnImprezaTouchStar
    > >
    > > 'connection details
    > > <% server.execute ("connections.inc") %>
    > >

    >
    > Your first error is in the last line I pasted above. Since you are already
    > in an ASP script block you cannot (and do not need to) enter another

    script
    > block in order to execute the Server.Execute call. If you weren't

    receiving
    > an error on this line (at te very least) then you mayhave deaper problems,

    as
    > this line is a syntax error that occurs before your On Error Resume Next
    >
    > -T


    In my page that line isn't there, the strings of my connection are there, i
    just put that there to show that some form of connection method is there,
    didn't wanna show the different server connection strings, paranoia on my
    part
     
    Steven Scaife, Aug 13, 2004
    #2
    1. Advertising

  3. Steven Scaife

    Tarwn Guest

    That explains a lot, I was trying to figure out how you would not be getting
    an error in that situation :)

    I've looked through the rest of your code and if it is a logic error, I am
    not seeing it. My assumption is that the line you rendered inoperable was
    the last SQL entry.

    An error should be thrown at that point, something to the effect of table
    not found. What type of database are you operating on (MS Access, SQL Server,
    etc)? Not sure it will matter but it may.

    One thing I would try is to cut it down to the minimal amount of code to try
    and duplicate the lack of error. Comment out everything except the connection
    string, creation of the connection object, the sql string, execution of the
    sql string, and a one line "If err.number <> 0 Then Response.Write
    err.description"

    If you get the error in that case then uncomment the
    dispError("imprezaTouchstar") line. Etc. Work your way from the most simple
    to the most broad.

    -T
     
    Tarwn, Aug 15, 2004
    #3
  4. Just noticed why it wouldn't work, i am calling disperror instead of
    disperr. Doh!

    thanks for the help

    "Steven Scaife" <> wrote in message
    news:...
    > Below is my ASP page, I have changed the update to read DRIAL which

    doesn't
    > exist, shouldnt this throw an error, or if the connection cannot be made
    > shouldnt it throw an error as well
    >
    > thanks in advance
    >
    > <%@language="VBScript"%>
    > <% option explicit %>
    > <% response.buffer = True %>
    >
    > <%
    > dim telNo, comp, adbTable
    > telNo = request.form("telNo")
    >
    > response.write telno & "<BR>"
    > comp = inStr(1, telNo, " ", 1)
    >
    > if comp <> 0 then
    > response.redirect "phone.asp?QS=yes&num=" & telno
    > end if
    > %>
    >
    > <%
    > Dim conn, RS, strSQL, strConnImpreza, strConnDom_Con,
    > strConnImprezaTouchStar
    >
    > 'connection details
    > <% server.execute ("connections.inc") %>
    > 'error checking starts here, if an error is encountered display a msg to

    the
    > user and carry on
    > on error resume next
    >
    > conn.open strConnImpreza
    >
    > 'this sql statement can be run on both impreza and dom_con tables Amcat'
    > strSQL = "INSERT INTO MasterDoNotCall(phonenum) VALUES ('" & telNo & "');"
    > conn.execute strSQL 'run the sql statement
    >
    > disperror("imprezanocall") 'call the error function
    >
    > response.write strSQL & "<BR>"
    > conn.close 'close the connection'
    >
    >
    > conn.open strConnDom_Con 'open the connection to dom_con'
    >
    > strSQL = "INSERT INTO MasterDoNotCall(phonenum) VALUES ('" & telNo & "');"
    > conn.execute strSQL
    >
    > disperror("DomConNoCall")
    >
    > response.write strSQL & "<BR>"
    > conn.close
    >
    >
    > 'for this table we need to run two sql statements, first open the
    > connection'
    > conn.open strConnImprezaTouchStar
    > disperror("connTouchstar")
    >
    > strSQL = "INSERT INTO Nevercall (PhoneNum, EffectiveDate) " & _
    > "VALUES ('" & telNo & "', Getdate())"
    > conn.execute strQSL
    >
    > disperror("imprezaTouchstarNC")
    >
    > response.write strSQL & "<BR>"
    >
    > strSQL = "UPDATE DIAL SET CRC = 'DNC' WHERE PhoneNum = '" & telNo & "';"
    > conn.execute strSQL
    >
    > disperror("imprezaTouchstar")
    >
    > response.write strSQL & "<BR>"
    >
    >
    > conn.close
    > set conn = nothing
    >
    >
    > %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    >
    > <html>
    > <head>
    > <title>Updated Databases</title>
    > <style>
    > <!--
    > body { font-family: arial, helvetica, sans-serif; font-size: 10px; }
    > //-->
    > </style>
    > </head>
    >
    > <body>
    > Detail have been inserted into the corresponding databases
    >
    >
    > </body>
    > </html>
    > <%
    > sub dispErr(adbTable)
    > ' if an error is raised then trap it here and end processing
    > IF err.number <> 0 then
    > %>
    >
    > <p>Record already exists on the server and table.</p>
    > <%
    > SELECT CASE adbTable
    > case "imprezanocall" %>
    > <p>Server: Impreza, Database: AMcat, Table: MasterDonotcall; Was not
    > updated</p>
    > <% case "DomConNoCall" %>
    > <p>Server: Dom_Call, Database: AMcat, Table: MasterDonotcall; Was not
    > updated</p>
    > <% case "imprezaTouchstar" %>
    > <p>Server: Impreza, Database: Touchstar, Table: Dial; Was not
    > updated</p>
    > <% case "imprezaTouchstarNC" %>
    > <p>Server: Impreza, Database: Touchstar, Table: Nevercall; Was not
    > updated</p>
    > <% case "connTouchstar" %>
    > <p>Connection to Touchstar failed</p>
    > <% END SELECT
    > end if
    > Err.Clear
    >
    > end sub
    > %>
    >
    >
     
    Steven Scaife, Aug 16, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William F. Robertson, Jr.

    Re: Page_Load event doesn't appear in the trace

    William F. Robertson, Jr., Jun 25, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    890
    William F. Robertson, Jr.
    Jun 25, 2003
  2. Marina
    Replies:
    0
    Views:
    540
    Marina
    Jul 21, 2003
  3. Elliot M. Rodriguez
    Replies:
    0
    Views:
    613
    Elliot M. Rodriguez
    Jul 21, 2003
  4. Mufasa
    Replies:
    1
    Views:
    363
    bruce barker
    Jun 10, 2008
  5. Replies:
    7
    Views:
    1,151
    Lothar Kimmeringer
    Nov 6, 2008
Loading...

Share This Page