Please help with If Then Else code

R

robert

I cannot get these 'if then else response.write' codes to work can
someone please help

The database, I have two tables (relationship)

contactTBL (one) and membershipTBL (many)
contactTBL - primary key - contactID
membershipTBL - foreign key - contactID

All I want to do is set up a statement that returns a response.write
"no memberhsip on file" if contactID is not in the membershipTBL - ie
if the person has no membership, then their 'contactID' would not
appear in the membershipTBL, and I would like to tell them when they
login that 'You dont have any membership'

Here is some code that may help, the site is protected by the
contactID set as CID:

<%Your_Name = request.cookies("remain")%>
<%Date_In = request.cookies("still")%>
<%CID = request.cookies("CID")%>
<%If request.cookies("remain") = "" then response.redirect
("login.html")%>
<%Dim MyLogin

Set MyLogin = Server.CreateObject("ADODB.Connection")
ConnStr = "DRIVER={Microsoft Access Driver (*.mdb)}; "
ConnStr = ConnStr & "DBQ=" & Server.MapPath("..\fpdb\aata.mdb")
MyLogin.Open(ConnStr)
%>
</html>
<body>
<%dim oRS
Set oRS= MyLogin.execute("Select * From membership_TBL WHERE
contactID=" & CID & "")%>
<%If oRS.EOF = " " AND oRS.BOF = " " then response.write "You have no
membership"%>

--

The error is ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record

Note there is another connection above this in the code to another
table in the database, that code is:

<%Dim RS
Set RS = MyLogin.execute("SELECT * FROM contactTBL WHERE contactID=" &
CID & "")
%>
Welcome, <%=Your_Name%>

Thanks in Advance
Rob
 
S

Stefan B Rusynko

For no records found should just be
<% If oRS.EOF then response.write "You have no membership"%>


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


|I cannot get these 'if then else response.write' codes to work can
| someone please help
|
| The database, I have two tables (relationship)
|
| contactTBL (one) and membershipTBL (many)
| contactTBL - primary key - contactID
| membershipTBL - foreign key - contactID
|
| All I want to do is set up a statement that returns a response.write
| "no memberhsip on file" if contactID is not in the membershipTBL - ie
| if the person has no membership, then their 'contactID' would not
| appear in the membershipTBL, and I would like to tell them when they
| login that 'You dont have any membership'
|
| Here is some code that may help, the site is protected by the
| contactID set as CID:
|
| <%Your_Name = request.cookies("remain")%>
| <%Date_In = request.cookies("still")%>
| <%CID = request.cookies("CID")%>
| <%If request.cookies("remain") = "" then response.redirect
| ("login.html")%>
| <%Dim MyLogin
|
| Set MyLogin = Server.CreateObject("ADODB.Connection")
| ConnStr = "DRIVER={Microsoft Access Driver (*.mdb)}; "
| ConnStr = ConnStr & "DBQ=" & Server.MapPath("..\fpdb\aata.mdb")
| MyLogin.Open(ConnStr)
| %>
| </html>
| <body>
| <%dim oRS
| Set oRS= MyLogin.execute("Select * From membership_TBL WHERE
| contactID=" & CID & "")%>
| <%If oRS.EOF = " " AND oRS.BOF = " " then response.write "You have no
| membership"%>
|
| --
|
| The error is ADODB.Field error '80020009'
|
| Either BOF or EOF is True, or the current record has been deleted.
| Requested operation requires a current record
|
| Note there is another connection above this in the code to another
| table in the database, that code is:
|
| <%Dim RS
| Set RS = MyLogin.execute("SELECT * FROM contactTBL WHERE contactID=" &
| CID & "")
| %>
| Welcome, <%=Your_Name%>
|
| Thanks in Advance
| Rob
|
 
R

robert

For no records found should just be
<% If oRS.EOF then response.write "You have no membership"%>

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


|I cannot get these 'if then else response.write' codes to work can
| someone please help
|
| The database, I have two tables (relationship)
|
| contactTBL (one) and membershipTBL (many)
| contactTBL - primary key - contactID
| membershipTBL - foreign key - contactID
|
| All I want to do is set up a statement that returns a response.write
| "no memberhsip on file" if contactID is not in the membershipTBL - ie
| if the person has no membership, then their 'contactID' would not
| appear in the membershipTBL, and I would like to tell them when they
| login that 'You dont have any membership'
|
| Here is some code that may help, the site is protected by the
| contactID set as CID:
|
| <%Your_Name = request.cookies("remain")%>
| <%Date_In = request.cookies("still")%>
| <%CID = request.cookies("CID")%>
| <%If request.cookies("remain") = "" then response.redirect
| ("login.html")%>
| <%Dim MyLogin
|
| Set MyLogin = Server.CreateObject("ADODB.Connection")
| ConnStr = "DRIVER={Microsoft Access Driver (*.mdb)}; "
| ConnStr = ConnStr & "DBQ=" & Server.MapPath("..\fpdb\aata.mdb")
| MyLogin.Open(ConnStr)
| %>
| </html>
| <body>
| <%dim oRS
| Set oRS= MyLogin.execute("Select * From membership_TBL WHERE
| contactID=" & CID & "")%>
| <%If oRS.EOF = " " AND oRS.BOF = " " then response.write "You have no
| membership"%>
|
| --
|
| The error is ADODB.Field error '80020009'
|
| Either BOF or EOF is True, or the current record has been deleted.
| Requested operation requires a current record
|
| Note there is another connection above this in the code to another
| table in the database, that code is:
|
| <%Dim RS
| Set RS = MyLogin.execute("SELECT * FROM contactTBL WHERE contactID=" &
| CID & "")
| %>
| Welcome, <%=Your_Name%>
|
| Thanks in Advance
| Rob
|

I swear that didnt work yesterday! I must have typed something wrong
when I tested it. THANKS!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top