Home All Groups Group Topic Archive Search About


Author
24 Jun 2006 4:41 PM
solomon_13000
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

Author
24 Jun 2006 5:43 PM
Bob Barrows [MVP]
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:

Show quote
> 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
Show quote
> 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

Show quote
> 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"
Author
24 Jun 2006 5:53 PM
solomon_13000
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:
Show quote
> 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
Author
24 Jun 2006 7:27 PM
Bob Barrows [MVP]
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"

AddThis Social Bookmark Button