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.