Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 22nd, 2003, 08:59 AM
wasssup wasssup is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: mi
Posts: 2 wasssup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to wasssup
Post help with if exist plz

I am having trouble getting this code to work. I want to check the email submited to my access db via post then if the email already exist then tell the user they need to choose another email address because this on already is in there. here is my code:


<%
Response.Buffer = true
dim conn,rsE
set conn = Server.CreateObject("ADODB.Connection")
set rsE = Server.CreateObject("ADODB.RecordSet")
conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=members.mdb;"
sqltext = "SELECT Email FROM Results WHERE Email=('" & request.Form("Email") & "') "
rsE.Open sqltext,conn,3,3
WHILE NOT rsE.EOF
rsE.MoveNext
If rsE.EOF and rsE.Bof_then
Response.Write("ok")
end if
'do nothing because the Email does not already exists

Else

‘read through the recordset, see if Email matches another
If rsE("Email") = Request.form("Email") Then
Response.Write ("The Email you have entered already exist. Multiple accounts are not allowed Please use a different Email Address.")
Response.End
End If
rsE.Close
conn.Close
%>

Can someone check it and tell me what might be wrong with it. thanks -wasssup

Reply With Quote
  #2  
Old November 23rd, 2003, 04:43 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
What error message are you getting, can you specify which line errors out.

S-

Reply With Quote
  #3  
Old November 23rd, 2003, 08:21 PM
wasssup wasssup is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: mi
Posts: 2 wasssup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to wasssup
At the time of my post I couldnt get any error due to my IE setting. I fixed that and was able to work the code til I got it working. I came up with a fix and have been running it. Here is that code: any one can use it if they like or if you can inprove it cool just share with me.. Thanks for your reply though. -wasssup

<%
DIM strEmail, conn, rsE
strEmail = Request.Form("Email")
IF strEmail <> "" AND inStr(strEmail,"@") <> 0 AND inStr(strEmail,".") <> 0 THEN

' Enter form to database or send via email

ELSE

Response.Write "<p>Please click Back on your browser and complete the following field:</p>"

IF strEmail <> "" THEN
ELSE
Response.Write "<b>• Email</b><br>"
END IF
IF inStr(strEmail,"@") <> 0 THEN
ELSE
Response.Write "<b>• You entered an invalid Email Address</b><br>"
Response.End
END IF
IF inStr(strEmail,".") <> 0 THEN
ELSE
Response.Write "<b>• You entered an invalid Email Address</b><br>"
Response.End
END IF

END IF

set conn=Server.CreateObject("ADODB.Connection")
set rsE=Server.CreateObject("ADODB.RecordSet")
conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=somedatabase.mdb;"
rsE.Open "select Email from sometable where Email='" & strEmail & "'",conn,adOpenDynamic,1
'search the email
'assumption : one email for one person - no redundancy
if not rsE.Bof and not rsE.Eof then
'already exists
Response.Write"<b>• The Email you have entered already exist. Multiple accounts are not allowed.<br>• Please click on your back button and use a different Email Address.</b>"
Response.End

ELSE

'not exists
End if

rsE.Close
conn.Close
set rsE=Nothing
set conn=Nothing
%>

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > help with if exist plz


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT