code execution

Discussion in 'ASP General' started by solomon_13000, Jun 24, 2006.

  1. The problem with the code bellow is that suppose I change the valid
    database name from stelladb.mdb to an invalid database name stella.mdb,
    what happens is the following statement gets executed:

    response.write "<center><font class='error'>Error: Username is
    unavailable</font></center><br><br>"

    Response.Write "<center><font class='error'>" & Err.number & ":" &
    Err.Description & "</font></center><br>"

    By right only the statement bellow is suppose to get executed:

    Response.Write "<center><font class='error'>" & Err.number & ":" &
    Err.Description & "</font></center><br>"

    How do I solve the problem:


    Complete code:


    on error resume next
    set conn = Server.CreateObject("ADODB.Connection")
    conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
    Server.MapPath("/db/upload/stelladb.md") & ";"
    set rs = Server.CreateObject("ADODB.Recordset")
    conn.qDupUser p1,rs
    If not rs.eof then
    If rs(0) = 1 then
    response.write "<center><font class='error'>Error: Username is
    unavailable</font></center><br><br>"
    session("duplicate") = "true"
    else
    session("duplicate") = "false"
    end if
    Else
    response.write "<center><font class='error'>Error: No records
    returned</font></center><br><br>"
    End if
    If Err.number <> 0 then
    Response.Write "<center><font class='error'>" & Err.number & ":" &
    Err.Description & "</font></center><br>"
    Else
    conn.close
    set conn = nothing
    if session("duplicate") = "false" then
    InsertQueryString p1,p2,p3
    end if
    End if
    on Error goto 0


    Sub InsertQueryString(p1,p2,p3)
    arParms = Array(p1,p2,p3)
    sql = "INSERT INTO Account([Username],[Password],[Type]) VALUES(?,?,?)"

    RunQueryString sql, arParms
    End Sub
     
    solomon_13000, Jun 24, 2006
    #1
    1. Advertising

  2. solomon_13000 wrote:
    > The problem with the code bellow is that suppose I change the valid
    > database name from stelladb.mdb to an invalid database name
    > stella.mdb,


    So stella.mdb is an actual database, so your conn.open statement does not
    throw an error?
    Change the code as shown below:

    > what happens is the following statement gets executed:
    >
    > response.write "<center><font class='error'>Error: Username is
    > unavailable</font></center><br><br>"
    >
    > Response.Write "<center><font class='error'>" & Err.number & ":" &
    > Err.Description & "</font></center><br>"
    >
    > By right only the statement bellow is suppose to get executed:
    >
    > Response.Write "<center><font class='error'>" & Err.number & ":" &
    > Err.Description & "</font></center><br>"
    >
    > How do I solve the problem:
    >
    >
    > Complete code:
    >
    >
    > on error resume next
    > set conn = Server.CreateObject("ADODB.Connection")
    > conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
    > Server.MapPath("/db/upload/stelladb.md") & ";"


    if err<>0 then
    > response.write "<center><font class='error'>Error: Username is
    > unavailable</font></center><br><br>"
    > session("duplicate") = "true"

    else
    > set rs = Server.CreateObject("ADODB.Recordset")
    > conn.qDupUser p1,rs
    > If not rs.eof then
    > If rs(0) = 1 then
    > response.write "<center><font class='error'>Error: Username is
    > unavailable</font></center><br><br>"
    > session("duplicate") = "true"
    > else
    > session("duplicate") = "false"
    > end if
    > Else
    > response.write "<center><font class='error'>Error: No records
    > returned</font></center><br><br>"
    > End if
    > If Err.number <> 0 then
    > Response.Write "<center><font class='error'>" & Err.number & ":" &
    > Err.Description & "</font></center><br>"
    > Else
    > conn.close
    > set conn = nothing
    > if session("duplicate") = "false" then
    > InsertQueryString p1,p2,p3
    > end if
    > End if


    End if

    > on Error goto 0
    >
    >
    > Sub InsertQueryString(p1,p2,p3)
    > arParms = Array(p1,p2,p3)
    > sql = "INSERT INTO Account([Username],[Password],[Type])
    > VALUES(?,?,?)"
    >
    > RunQueryString sql, arParms
    > End Sub


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jun 24, 2006
    #2
    1. Advertising

  3. valid database name:stelladb.mdb
    invalid database name: stella.mdb

    It does throw an error message using an invalid db name:

    Response.Write "<center><font class='error'>" & Err.number & ":" &
    Err.Description & "</font></center><br>"

    but the code also displays the following error msg which is not suppose
    to be displayed:

    response.write "<center><font class='error'>Error: Username is
    unavailable</font></center><br><br>"



    solomon_13000 wrote:
    > The problem with the code bellow is that suppose I change the valid
    > database name from stelladb.mdb to an invalid database name stella.mdb,
    > what happens is the following statement gets executed:
    >
    > response.write "<center><font class='error'>Error: Username is
    > unavailable</font></center><br><br>"
    >
    > Response.Write "<center><font class='error'>" & Err.number & ":" &
    > Err.Description & "</font></center><br>"
    >
    > By right only the statement bellow is suppose to get executed:
    >
    > Response.Write "<center><font class='error'>" & Err.number & ":" &
    > Err.Description & "</font></center><br>"
    >
    > How do I solve the problem:
    >
    >
    > Complete code:
    >
    >
    > on error resume next
    > set conn = Server.CreateObject("ADODB.Connection")
    > conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
    > Server.MapPath("/db/upload/stelladb.md") & ";"
    > set rs = Server.CreateObject("ADODB.Recordset")
    > conn.qDupUser p1,rs
    > If not rs.eof then
    > If rs(0) = 1 then
    > response.write "<center><font class='error'>Error: Username is
    > unavailable</font></center><br><br>"
    > session("duplicate") = "true"
    > else
    > session("duplicate") = "false"
    > end if
    > Else
    > response.write "<center><font class='error'>Error: No records
    > returned</font></center><br><br>"
    > End if
    > If Err.number <> 0 then
    > Response.Write "<center><font class='error'>" & Err.number & ":" &
    > Err.Description & "</font></center><br>"
    > Else
    > conn.close
    > set conn = nothing
    > if session("duplicate") = "false" then
    > InsertQueryString p1,p2,p3
    > end if
    > End if
    > on Error goto 0
    >
    >
    > Sub InsertQueryString(p1,p2,p3)
    > arParms = Array(p1,p2,p3)
    > sql = "INSERT INTO Account([Username],[Password],[Type]) VALUES(?,?,?)"
    >
    > RunQueryString sql, arParms
    > End Sub
     
    solomon_13000, Jun 24, 2006
    #3
  4. solomon_13000 wrote:
    > valid database name:stelladb.mdb
    > invalid database name: stella.mdb
    >
    > It does throw an error message using an invalid db name:
    >
    > Response.Write "<center><font class='error'>" & Err.number & ":" &
    > Err.Description & "</font></center><br>"
    >
    > but the code also displays the following error msg which is not
    > suppose to be displayed:
    >
    > response.write "<center><font class='error'>Error: Username is
    > unavailable</font></center><br><br>"
    >

    Well change it to display the message you want it to display in the if err
    <> 0 then block. (hopefully, you made the changes I suggested - it will be
    really helpful if you post your code revisions in any followups to this).

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jun 24, 2006
    #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. John

    Back Button and code execution

    John, Jul 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    510
    Yan-Hong Huang[MSFT]
    Aug 1, 2003
  2. Ronnie Scott

    Execution of code-behind without postback

    Ronnie Scott, Nov 27, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    753
    Iguana
    Nov 28, 2003
  3. Pavils Jurjans

    ASP page initiating complex code execution

    Pavils Jurjans, Feb 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    375
    Tommy
    Feb 3, 2004
  4. Chris
    Replies:
    1
    Views:
    546
    Ashish M Bhonkiya
    May 13, 2004
  5. Phil Winstanley [Microsoft MVP]

    Re: Client\x2FServer-side execution of code

    Phil Winstanley [Microsoft MVP], May 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    445
    Phil Winstanley [Microsoft MVP]
    May 13, 2004
Loading...

Share This Page