473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

code execution

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

Jun 24 '06 #1
3 1419
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"
Jun 24 '06 #2
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


Jun 24 '06 #3
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"
Jun 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jo | last post by:
Hi, I have a small (hopefully!) problem. I have two buttons on my web page and when button A is clicked, the code behind takes about 3 seconds to execute. While it's executing though, I don't want...
1
by: Default | last post by:
Hi, I am new to C#, that is why I am not sure what kind of problem it is: Is VS files corrupted , or something else. that is the problems description: I am working on a small database project. I am...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
5
by: Adrian Enders | last post by:
I have something that I have never seen before in a MS development product. I have a pretty simple call to a network directory that looks something like this ... Dim dirFolder As...
88
by: Peter Olcott | last post by:
Cab you write code directly in the Common Intermediate language? I need to optimize a critical real-time function.
9
by: Rea | last post by:
Hi eb I set some 'Stop' statements and also visual breakpoints in asp code (vbscript). I am doing that in Microsoft Script debugger. Than I refresh the original page and expect execution to halt...
1
by: Sabiyur | last post by:
Hi All, I don't know whether this is the right forum to post this question. If not, Please forgive me. I want to write my own tool which can trace the code execution (print the sequence of...
3
by: poornibalu | last post by:
I want to stop the execution of the code when the value of k>100 in the function function aa() { if (k>100) { //command to kill the execution
7
by: Andrew Poulos | last post by:
If I have code that looks like this ajax = function(str) { var val = ""; // do some stuff here return val; }; var foo = ajax("string");
4
by: sphinney | last post by:
Hi everyone. I'm creating an application inside Access 2007. The application will retrieve data from various locations on my company's network servers. Depending on the time of day, alignment of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.