|
Home > Archive > IIS ASP > June 2006 > code execution
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| solomon_13000 2006-06-24, 1:20 pm |
| 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
| |
| Bob Barrows [MVP] 2006-06-24, 1:20 pm |
| 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"
| |
| solomon_13000 2006-06-24, 1:20 pm |
| 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
| |
| Bob Barrows [MVP] 2006-06-24, 7:20 pm |
| 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"
|
|
|
|
|