473,805 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with If logic ....repost

I am attempting to create a "new account creation" asp, but would ideally
like the routine to check the Access db for an existing email address and
username (called UID below). The select query called CheckAccount works as
expected within the db as does the append query CreateAccount. However, the
If statement below after DataConnection. CheckAccount obviously doesn't work
because if I attempt to create an account for which either a username or
email address already exists in the db, the DataConnection. CreateAccount
throws up an error, which should even have taken place in the first place.
Any ideas appreciated.

Dave

Here is what I have in the header. The Response.Writes are below.

<%
Dim p1, p2, p3, p4, p5, p6

p1 = Request.Form("G ivenName")
p2 = Request.Form("S urName")
p3 = Request.Form("P WD")
p4 = Request.Form("P WD2")
p5 = Request.Form("E mail")
p6 = Request.Form("U ID")

If LenB(Request.Fo rm("btnAdd")) <> 0 Then

If p3 = p4 Then
Dim DataConnection, RecordSet, strError1, strError2, strError3
Set DataConnection = Server.CreateOb ject("ADODB.Con nection")
DataConnection. Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=" & DatabasePath & ";"
Set RecordSet = Server.CreateOb ject("ADODB.Rec ordset")
DataConnection. CheckAccount p5, p6, RecordSet

If Not RecordSet.EOF Then
If RecordSet.Field s("Email") = p5 Then
strError1 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry,
this Email address is taken.</B></FONT>"
Else
strError2 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry,
this Username is taken.</B></FONT>"
End if
RecordSet.Close
Set RecordSet=Nothi ng
DataConnection. Close
Set DataConnection= Nothing
Else
RecordSet.Close
Set RecordSet = Nothing
DataConnection. CreateAccount p1, p2, p3, p5, p6
Session("ID") = p6
DataConnection. Close
Set DataConnection = Nothing
Response.Redire ct "createprofile. asp"
Response.End
End if
Else
strError3 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry, your passwords
didn't match.</B></FONT>"
End If
End if
%>

<%
Response.Write (strError1)
Response.Write (strError2)
Response.Write (strError3)
%>

With Text form boxes named GivenName, SurName, PWD, PWD2, Email, UID where
PWD2 doesn't have a field in the db and is merely a check for the client.

Thanks,

Dave
Recommendations :
1. Better indenting so you can see where your if...else...end if blocks
begin
and end
2. Use Response.Write to see what is happening.
3. I see no action being taken in the event of error 1 or 2, but that
could
be because I can't follow your logic due to the lack of proper indenting.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

--
_______________ _______________
Remove "_SPAM" to reply directly.
Jul 22 '05 #1
7 1653
"David Shorthouse" wrote in message
news:u6******** ******@tk2msftn gp13.phx.gbl...
:I am attempting to create a "new account creation" asp, but would ideally
: like the routine to check the Access db for an existing email address and
: username (called UID below). The select query called CheckAccount works as
: expected within the db as does the append query CreateAccount. However,
the
: If statement below after DataConnection. CheckAccount obviously doesn't
work
: because if I attempt to create an account for which either a username or
: email address already exists in the db, the DataConnection. CreateAccount
: throws up an error, which should even have taken place in the first place.
: Any ideas appreciated.

Hi Dave.

: Here is what I have in the header. The Response.Writes are below.
:
: <%
: Dim p1, p2, p3, p4, p5, p6
:
: p1 = Request.Form("G ivenName")
: p2 = Request.Form("S urName")
: p3 = Request.Form("P WD")
: p4 = Request.Form("P WD2")
: p5 = Request.Form("E mail")
: p6 = Request.Form("U ID")
:
: If LenB(Request.Fo rm("btnAdd")) <> 0 Then
:
: If p3 = p4 Then
: Dim DataConnection, RecordSet, strError1, strError2, strError3
: Set DataConnection = Server.CreateOb ject("ADODB.Con nection")
: DataConnection. Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data
: Source=" & DatabasePath & ";"
: Set RecordSet = Server.CreateOb ject("ADODB.Rec ordset")
: DataConnection. CheckAccount p5, p6, RecordSet
:
: If Not RecordSet.EOF Then
: If RecordSet.Field s("Email") = p5 Then
: strError1 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry,
: this Email address is taken.</B></FONT>"
: Else
: strError2 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry,
: this Username is taken.</B></FONT>"
: End if
: RecordSet.Close
: Set RecordSet=Nothi ng
: DataConnection. Close
: Set DataConnection= Nothing
: Else
: RecordSet.Close
: Set RecordSet = Nothing
: DataConnection. CreateAccount p1, p2, p3, p5, p6
: Session("ID") = p6
: DataConnection. Close
: Set DataConnection = Nothing
: Response.Redire ct "createprofile. asp"
: Response.End
: End if
: Else
: strError3 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry, your passwords
: didn't match.</B></FONT>"
: End If
: End if
: %>
:
: <%
: Response.Write (strError1)
: Response.Write (strError2)
: Response.Write (strError3)
: %>
:
: With Text form boxes named GivenName, SurName, PWD, PWD2, Email, UID where
: PWD2 doesn't have a field in the db and is merely a check for the client.

So, turn it around and compare that way? if RecordSet.eof then
Or, perhaps the cursor is at the eof. Showing the query might be needed.

FYI... I don't see a need for strError1, etc. Just write out the error
unless this is a cut-down version of the page and there's something between
the two script blocks and then I would pass it to a sub.

sub reportError(err Num)
Response.Write "<span style=""font: bold small arial"">Sorry, "
select case errNum
case 1
Response.Write "this email address is taken."
case 2
Response.Write "this username is taken."
case 3
Response.Write "you passwords do not match."
case else
end select
Response.Write "</span>" & "<br />" & vbCrLf
end sub

So, this:
strError1 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry, this Email address is
taken.</B></FONT>"

becomes this:
reportError(1)

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #2
CJM
David,

Why call your variables P1 - P6? This is meaningless and makes it very hard
to debug. What is wrong with sForename, sSurname etc...?

Also, I wouldnt call your recordset 'RecordDet'. This is a reserved word,
and if it doesnt invoke and error it really ought to... How about rsAccount
or similar?

Digging deeper, it appears that you might be getting something back from
your query [thus .EOF is not True]. You might want to investigate what it is
you are getting retruned... Try finding if you are getting values for
rsAccount(0), rsAccount(1) etc...

Chris
Jul 22 '05 #3
CJM wrote:
David,

Why call your variables P1 - P6? This is meaningless and makes it
very hard to debug. What is wrong with sForename, sSurname etc...?

Also, I wouldnt call your recordset 'RecordDet'. This is a reserved
word, and if it doesnt invoke and error it really ought to... How
about rsAccount or similar?

Digging deeper, it appears that you might be getting something back
from your query [thus .EOF is not True]. You might want to
investigate what it is you are getting retruned... Try finding if you
are getting values for rsAccount(0), rsAccount(1) etc...

Chris

Unfortunately, with two threads going, this has become confusing. In the
original thread, David states that he has solved his problem.

You both have offered some good suggestions, all the same.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #4
Gazing into my crystal ball I observed "Roland Hall" <nobody@nowhere >
writing in news:uf******** ******@TK2MSFTN GP12.phx.gbl:
sub reportError(err Num)
Response.Write "<span style=""font: bold small arial"">Sorry, "
select case errNum
case 1
Response.Write "this email address is taken."
case 2
Response.Write "this username is taken."
case 3
Response.Write "you passwords do not match."
case else
end select
Response.Write "</span>" & "<br />" & vbCrLf
end sub

So, this:
strError1 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry, this Email address is
taken.</B></FONT>"

becomes this:
reportError(1)


Even better:
Response.write "<span class='error'>. ..</span>"

Then define your error styling in an external sheet. Much easier to deal
with if you need to change that error styling later on.

--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Jul 22 '05 #5
Oops. Sorry about the two posts and not replying to my own post in this
thread. Indeed, I did solve the problem and the solution is in the previous
thread.

--
_______________ _______________
Remove "_SPAM" to reply directly.

"David Shorthouse" <davidshorthous e@shaw_SPAM.ca> wrote in message
news:u6******** ******@tk2msftn gp13.phx.gbl...
I am attempting to create a "new account creation" asp, but would ideally
like the routine to check the Access db for an existing email address and
username (called UID below). The select query called CheckAccount works as
expected within the db as does the append query CreateAccount. However, the
If statement below after DataConnection. CheckAccount obviously doesn't work
because if I attempt to create an account for which either a username or
email address already exists in the db, the DataConnection. CreateAccount
throws up an error, which should even have taken place in the first place.
Any ideas appreciated.

Dave

Jul 22 '05 #6
"Adrienne" wrote in message
news:Xn******** *************** *****@207.115.6 3.158...
: Gazing into my crystal ball I observed "Roland Hall" <nobody@nowhere >
: writing in news:uf******** ******@TK2MSFTN GP12.phx.gbl:
:
: > sub reportError(err Num)
: > Response.Write "<span style=""font: bold small arial"">Sorry, "
: > select case errNum
: > case 1
: > Response.Write "this email address is taken."
: > case 2
: > Response.Write "this username is taken."
: > case 3
: > Response.Write "you passwords do not match."
: > case else
: > end select
: > Response.Write "</span>" & "<br />" & vbCrLf
: > end sub
: >
: > So, this:
: > strError1 = "<FONT FACE='ARIAL' SIZE='3'><B>Sor ry, this Email address is
: > taken.</B></FONT>"
: >
: > becomes this:
: > reportError(1)
: >
:
: Even better:
: Response.write "<span class='error'>. ..</span>"
:
: Then define your error styling in an external sheet. Much easier to deal
: with if you need to change that error styling later on.

Nice catch Adrienne.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #7
"David Shorthouse" wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
: Oops. Sorry about the two posts and not replying to my own post in this
: thread. Indeed, I did solve the problem and the solution is in the
previous
: thread.

Silly me. I read the whole other post but I thought this was after you
thought you had it working. Sorry about that. *sheepish grin*

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #8

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

Similar topics

2
1266
by: Dave | last post by:
Hi, this is a repost of a problem I am new to .Net and for my first application I have a form with a couple of databound dropdown lists, these work fine, i also have a button which pops up a calendar and allows the user to select a date, which fills in a textbox, all this works fine as individual processes, the problem is that if the user selects anything from the dropdowns, then selects the calendar, it completely clears the dropdowns...
117
7278
by: Peter Olcott | last post by:
www.halting-problem.com
4
1633
by: Ben | last post by:
I get an error when the compilator tries to link the object files of my program. I have the files group.h and group.c that use a struct define in logic.h and two fonctions define in logic.c. The program compile group.o fine, but when trying to link, I get an error in group.h saying that a struct that is defined in logic.h cannot be found. Include logic.h is explicitly call in group.h because it used an instance of that struct. What I...
2
1312
by: Gerry | last post by:
I have a combo box and I can populate it with my class of dat (the class allows me to store each userid,username called - see code below I want the user to select the dropdown and see the username - but also determine the UserID from what was selected (using DisplayName from the combo box?? I can populate the combo box without problems - BUT the user sees "System.object" in each item of the combobox not the username ***here is my clas...
18
1803
by: jslowery | last post by:
I am not completely knowledgable about the status of lexical scoping in Python, but it was my understanding that this was added in a long time ago around python2.1-python2.2 I am using python2.4 and the following code throws a "status variable" not found in the inner-most function, even when I try to "global" it. def collect(fields, reducer): def rule(record): status = True
2
1455
by: Raj | last post by:
Hi, I have the following problem. I am displaying and printing a PDF file that is generated by my Application server. The print dialogs comes up correctly for the small PDF for the larger PDFs ,the print dialog for the Acrobat reader does not comes up. I believe this is because print method is called before the complete loading of the PDF document. <html> <Head> <script>
4
1968
by: Earl Anderson | last post by:
I guess I missed the boat on the logic for this one. Immediately upon hitting "Import" in an attempt to import an Excel file containing 7 columns of 'txt' formatted data into AXP, I got a "Type mismatch" error. A search of previous posts indicated that Access did not 'like' most data types being imported except for 'txt' files, so I saved the 'xls' as 'txt' and that didn't work either, receiving the same "mismatch" error message. ...
0
1374
by: radhi | last post by:
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html> <HEAD> <%@ page contentType="application/msexcel" %> <% response.addHeader("Content-Disposition","inline; filename="+ "CONTRACTSAMENDMENTHISTORYEXCEL.xls" + ";" );
11
2096
by: =?ISO-8859-1?Q?Jean=2DFran=E7ois_Michaud?= | last post by:
Context: I'm trying to compare XML tree fragments and I'm doing so by outputting the attributes of each element in the tree and outputting it to a string then normalizing the strings. Then I'm doing a contains of the current string against the following-sibling::* to determine if we have duplicates. If we have a duplicate, we move to the next item, if there is no duplicate, we output the small tree. I'm hitting a completely ridiculous...
0
10609
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10105
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9185
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5542
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.