RS.EOF RS.BOF
am 14.01.2005 17:53:17 von Jim in Arizona
I'm having a little problem with conditioning formatting.
This is a page that, when loaded, puts the
Request.ServerVariables("AUTH_USER") into a variable. It then checks to see
if that name has already been logged to a table in an access2000 database.
If it has, then they should get a message saying they've already voted. If
not, then it should show a form where they can type in the name they're
voting for, click the submit, and the vote be logged to a table, at the same
time, the AUTH_USER is logged to a table so when they come back, they get
the "you've alredy voted" message.
I'm having problems with the BOF EOF condition formatting. I'm not sure how
to do it properly. I've tried, but this is the error message I usually end
up with:
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested
operation requires a current record.
/castvote.asp, line 43
Here is my code:
<%@ Language=VBScript %>
<%
OPTION EXPLICIT
Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
empname = Request.ServerVariables("AUTH_USER")
votename = Request.Form("vote")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
server.mappath("eoty.mdb")
SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" & empname &
"')"
SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
Set RS = Conn.Execute(SQL1,,1)
Sub Vote
If votename = "" Then
formcode
Response.Write "
You Must Type A Name"
Else
Conn.Execute SQL2,,1
Conn.Execute SQL3,,1
Response.Write "Thank You For Voting"
End If
End Sub
Sub NoVote
Response.Write "You've Already Voted"
End Sub
Sub formcode
%>
<%
End Sub
loggeduser = RS.Fields("voter")
%>
Cast Your Vote!
<%
If loggeduser = empname Then
NoVote
Else
Vote
End If
%>
Line 43 from the error message is loggeduser=RS.Fields("voter")
I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm not
sure what Im doing with it or how to properly use it.
The table starts out empty but since the SQL statement is selecting a record
that doesn't exist, it shouldn't matter if the table is empty or not, right?
Thanks in advance,
Jim
Re: RS.EOF RS.BOF
am 14.01.2005 18:13:33 von Steven Burn
Your using the "where" clause for a record that potentially, does not exist.
You need to check for it's existence first, and go from there (if it doesn't
exist, do not use the where clause).
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Jim in Arizona" wrote in message
news:#gAapml#EHA.3328@TK2MSFTNGP10.phx.gbl...
> I'm having a little problem with conditioning formatting.
>
> This is a page that, when loaded, puts the
> Request.ServerVariables("AUTH_USER") into a variable. It then checks to
see
> if that name has already been logged to a table in an access2000 database.
> If it has, then they should get a message saying they've already voted. If
> not, then it should show a form where they can type in the name they're
> voting for, click the submit, and the vote be logged to a table, at the
same
> time, the AUTH_USER is logged to a table so when they come back, they get
> the "you've alredy voted" message.
>
> I'm having problems with the BOF EOF condition formatting. I'm not sure
how
> to do it properly. I've tried, but this is the error message I usually end
> up with:
>
> Error Type:
> ADODB.Field (0x800A0BCD)
> Either BOF or EOF is True, or the current record has been deleted.
Requested
> operation requires a current record.
> /castvote.asp, line 43
>
> Here is my code:
>
> <%@ Language=VBScript %>
> <%
> OPTION EXPLICIT
>
> Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
>
> empname = Request.ServerVariables("AUTH_USER")
> votename = Request.Form("vote")
>
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> server.mappath("eoty.mdb")
>
> SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" & empname &
> "')"
> SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
> SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
>
> Set RS = Conn.Execute(SQL1,,1)
>
> Sub Vote
> If votename = "" Then
> formcode
> Response.Write "
You Must Type A Name"
> Else
> Conn.Execute SQL2,,1
> Conn.Execute SQL3,,1
> Response.Write "Thank You For Voting"
> End If
> End Sub
>
> Sub NoVote
> Response.Write "You've Already Voted"
> End Sub
>
> Sub formcode
> %>
>
> <%
> End Sub
>
> loggeduser = RS.Fields("voter")
> %>
> Cast Your Vote!
> <%
> If loggeduser = empname Then
> NoVote
> Else
> Vote
> End If
> %>
>
>
> Line 43 from the error message is loggeduser=RS.Fields("voter")
>
> I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm not
> sure what Im doing with it or how to properly use it.
> The table starts out empty but since the SQL statement is selecting a
record
> that doesn't exist, it shouldn't matter if the table is empty or not,
right?
>
> Thanks in advance,
> Jim
>
>
Re: RS.EOF RS.BOF
am 14.01.2005 18:13:59 von Mark Schupp
1. protect yourself from embedded single quotes.
SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" &
Replace(empname, "'", "''") & "')"
2. if no record is found then you cannot access the data. Is EOF to
determine if the user has voted.
%>
>
Cast Your Vote!
> <%
Set RS = Conn.Execute(SQL1,,1)
If rs.eof then
NoVote
Else
Vote
End If
> %>
3. alway close recordsets and connections and set them to nothing
Set RS = Conn.Execute(SQL1,,1)
If rs.eof then
NoVote
Else
Vote
End If
rs.close
set rs= nothing
conn.close
set conn = nothing
--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Jim in Arizona" wrote in message
news:%23gAapml%23EHA.3328@TK2MSFTNGP10.phx.gbl...
> I'm having a little problem with conditioning formatting.
>
> This is a page that, when loaded, puts the
> Request.ServerVariables("AUTH_USER") into a variable. It then checks to
> see if that name has already been logged to a table in an access2000
> database. If it has, then they should get a message saying they've already
> voted. If not, then it should show a form where they can type in the name
> they're voting for, click the submit, and the vote be logged to a table,
> at the same time, the AUTH_USER is logged to a table so when they come
> back, they get the "you've alredy voted" message.
>
> I'm having problems with the BOF EOF condition formatting. I'm not sure
> how to do it properly. I've tried, but this is the error message I usually
> end up with:
>
> Error Type:
> ADODB.Field (0x800A0BCD)
> Either BOF or EOF is True, or the current record has been deleted.
> Requested operation requires a current record.
> /castvote.asp, line 43
>
> Here is my code:
>
> <%@ Language=VBScript %>
> <%
> OPTION EXPLICIT
>
> Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
>
> empname = Request.ServerVariables("AUTH_USER")
> votename = Request.Form("vote")
>
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> server.mappath("eoty.mdb")
>
> SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" & empname &
> "')"
> SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
> SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
>
> Set RS = Conn.Execute(SQL1,,1)
>
> Sub Vote
> If votename = "" Then
> formcode
> Response.Write "
You Must Type A Name"
> Else
> Conn.Execute SQL2,,1
> Conn.Execute SQL3,,1
> Response.Write "Thank You For Voting"
> End If
> End Sub
>
> Sub NoVote
> Response.Write "You've Already Voted"
> End Sub
>
> Sub formcode
> %>
>
> <%
> End Sub
>
> loggeduser = RS.Fields("voter")
> %>
> Cast Your Vote!
> <%
> If loggeduser = empname Then
> NoVote
> Else
> Vote
> End If
> %>
>
>
> Line 43 from the error message is loggeduser=RS.Fields("voter")
>
> I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm not
> sure what Im doing with it or how to properly use it.
> The table starts out empty but since the SQL statement is selecting a
> record that doesn't exist, it shouldn't matter if the table is empty or
> not, right?
>
> Thanks in advance,
> Jim
>
Re: RS.EOF RS.BOF
am 14.01.2005 18:23:46 von Jim in Arizona
I don't know how I would do that, Steven.
"Steven Burn" wrote in message
news:%23FkpFyl%23EHA.2608@TK2MSFTNGP10.phx.gbl...
> Your using the "where" clause for a record that potentially, does not
> exist.
>
> You need to check for it's existence first, and go from there (if it
> doesn't
> exist, do not use the where clause).
>
> --
>
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "Jim in Arizona" wrote in message
> news:#gAapml#EHA.3328@TK2MSFTNGP10.phx.gbl...
>> I'm having a little problem with conditioning formatting.
>>
>> This is a page that, when loaded, puts the
>> Request.ServerVariables("AUTH_USER") into a variable. It then checks to
> see
>> if that name has already been logged to a table in an access2000
>> database.
>> If it has, then they should get a message saying they've already voted.
>> If
>> not, then it should show a form where they can type in the name they're
>> voting for, click the submit, and the vote be logged to a table, at the
> same
>> time, the AUTH_USER is logged to a table so when they come back, they get
>> the "you've alredy voted" message.
>>
>> I'm having problems with the BOF EOF condition formatting. I'm not sure
> how
>> to do it properly. I've tried, but this is the error message I usually
>> end
>> up with:
>>
>> Error Type:
>> ADODB.Field (0x800A0BCD)
>> Either BOF or EOF is True, or the current record has been deleted.
> Requested
>> operation requires a current record.
>> /castvote.asp, line 43
>>
>> Here is my code:
>>
>> <%@ Language=VBScript %>
>> <%
>> OPTION EXPLICIT
>>
>> Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
>>
>> empname = Request.ServerVariables("AUTH_USER")
>> votename = Request.Form("vote")
>>
>> Set Conn = Server.CreateObject("ADODB.Connection")
>> Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
>> server.mappath("eoty.mdb")
>>
>> SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" & empname
>> &
>> "')"
>> SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
>> SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
>>
>> Set RS = Conn.Execute(SQL1,,1)
>>
>> Sub Vote
>> If votename = "" Then
>> formcode
>> Response.Write "
You Must Type A Name"
>> Else
>> Conn.Execute SQL2,,1
>> Conn.Execute SQL3,,1
>> Response.Write "Thank You For Voting"
>> End If
>> End Sub
>>
>> Sub NoVote
>> Response.Write "You've Already Voted"
>> End Sub
>>
>> Sub formcode
>> %>
>>
>> <%
>> End Sub
>>
>> loggeduser = RS.Fields("voter")
>> %>
>> Cast Your Vote!
>> <%
>> If loggeduser = empname Then
>> NoVote
>> Else
>> Vote
>> End If
>> %>
>>
>>
>> Line 43 from the error message is loggeduser=RS.Fields("voter")
>>
>> I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm
>> not
>> sure what Im doing with it or how to properly use it.
>> The table starts out empty but since the SQL statement is selecting a
> record
>> that doesn't exist, it shouldn't matter if the table is empty or not,
> right?
>>
>> Thanks in advance,
>> Jim
>>
>>
>
>
Re: RS.EOF RS.BOF
am 14.01.2005 18:51:01 von Jim in Arizona
"Mark Schupp" wrote in message
news:uOikCyl%23EHA.2076@TK2MSFTNGP15.phx.gbl...
> 1. protect yourself from embedded single quotes.
> SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" &
> Replace(empname, "'", "''") & "')"
>
> 2. if no record is found then you cannot access the data. Is EOF to
> determine if the user has voted.
>
> %>
>> Cast Your Vote!
>> <%
> Set RS = Conn.Execute(SQL1,,1)
> If rs.eof then
> NoVote
> Else
> Vote
> End If
>> %>
>
> 3. alway close recordsets and connections and set them to nothing
>
> Set RS = Conn.Execute(SQL1,,1)
> If rs.eof then
> NoVote
> Else
> Vote
> End If
> rs.close
> set rs= nothing
> conn.close
> set conn = nothing
>
> --
> --Mark Schupp
> Head of Development
> Integrity eLearning
> www.ielearning.com
>
--snip--
Hi Mark.
I tried your approach but, with your suggested code:
If rs.eof then
NoVote
Else
Vote
End If
When the page was loaded, the NoVote sub procedure was executed even though
the table was completely empty. I tried doing this code as well:
If RS.EOF Then
Vote
Else
NoVote
End If
This is because if it is EOF then no data was retrieved, then they must not
have been here beofre. That being the case, then the Vote sub should be
executed, else, then they must have been here fore so the NoVote sub would
be executed. When I tried this, I wouldn't get an error, but the page would
execute the first part of the Vote sub procedure:
Sub Vote
If votename = "" Then
formcode
Response.Write "
Who Are You Voting For?"
Else
Conn.Execute SQL2,,1
Conn.Execute SQL3,,1
Response.Write "Thank You For Voting"
End If
End Sub
Sub formcode
%>
<%
End Sub
Obviously, it is now starting to work right, however my problem now lies in
my conditioning formatting if, when the page loads, no text has been
submitted. If not, it shows the form, as it should, and asks "Who are you
voting for?" but it doesn't process the SQL statements. I tried moving the
Request.Form like so:
Sub Vote
If votename = "" Then
formcode
Response.Write "
Who Are You Voting For?"
Else
votename = Request.Form("vote") 'added this line from the top of the
original set of code
Conn.Execute SQL2,,1
Conn.Execute SQL3,,1
Response.Write "Thank You For Voting"
End If
End Sub
This didn't make a difference. When I hit the submit button, I just get the
same thing and nothing is inserted into the tables.
Should I be using two seperate ASP pages to process this? I was hoping to do
it all on a single page.
I did add the closing statements, thanks.
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
Re: RS.EOF RS.BOF
am 14.01.2005 19:03:16 von Steven Burn
quick n dirty = connect to your database, open a recordset, use a Do/Loop to
check for it.
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Jim in Arizona" wrote in message
news:OBhWr3l#EHA.1936@TK2MSFTNGP10.phx.gbl...
> I don't know how I would do that, Steven.
>
>
>
> "Steven Burn" wrote in message
> news:%23FkpFyl%23EHA.2608@TK2MSFTNGP10.phx.gbl...
> > Your using the "where" clause for a record that potentially, does not
> > exist.
> >
> > You need to check for it's existence first, and go from there (if it
> > doesn't
> > exist, do not use the where clause).
> >
> > --
> >
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "Jim in Arizona" wrote in message
> > news:#gAapml#EHA.3328@TK2MSFTNGP10.phx.gbl...
> >> I'm having a little problem with conditioning formatting.
> >>
> >> This is a page that, when loaded, puts the
> >> Request.ServerVariables("AUTH_USER") into a variable. It then checks to
> > see
> >> if that name has already been logged to a table in an access2000
> >> database.
> >> If it has, then they should get a message saying they've already voted.
> >> If
> >> not, then it should show a form where they can type in the name they're
> >> voting for, click the submit, and the vote be logged to a table, at the
> > same
> >> time, the AUTH_USER is logged to a table so when they come back, they
get
> >> the "you've alredy voted" message.
> >>
> >> I'm having problems with the BOF EOF condition formatting. I'm not sure
> > how
> >> to do it properly. I've tried, but this is the error message I usually
> >> end
> >> up with:
> >>
> >> Error Type:
> >> ADODB.Field (0x800A0BCD)
> >> Either BOF or EOF is True, or the current record has been deleted.
> > Requested
> >> operation requires a current record.
> >> /castvote.asp, line 43
> >>
> >> Here is my code:
> >>
> >> <%@ Language=VBScript %>
> >> <%
> >> OPTION EXPLICIT
> >>
> >> Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
> >>
> >> empname = Request.ServerVariables("AUTH_USER")
> >> votename = Request.Form("vote")
> >>
> >> Set Conn = Server.CreateObject("ADODB.Connection")
> >> Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> >> server.mappath("eoty.mdb")
> >>
> >> SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" &
empname
> >> &
> >> "')"
> >> SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
> >> SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
> >>
> >> Set RS = Conn.Execute(SQL1,,1)
> >>
> >> Sub Vote
> >> If votename = "" Then
> >> formcode
> >> Response.Write "
You Must Type A Name"
> >> Else
> >> Conn.Execute SQL2,,1
> >> Conn.Execute SQL3,,1
> >> Response.Write "Thank You For Voting"
> >> End If
> >> End Sub
> >>
> >> Sub NoVote
> >> Response.Write "You've Already Voted"
> >> End Sub
> >>
> >> Sub formcode
> >> %>
> >>
> >> <%
> >> End Sub
> >>
> >> loggeduser = RS.Fields("voter")
> >> %>
> >> Cast Your Vote!
> >> <%
> >> If loggeduser = empname Then
> >> NoVote
> >> Else
> >> Vote
> >> End If
> >> %>
> >>
> >>
> >> Line 43 from the error message is loggeduser=RS.Fields("voter")
> >>
> >> I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm
> >> not
> >> sure what Im doing with it or how to properly use it.
> >> The table starts out empty but since the SQL statement is selecting a
> > record
> >> that doesn't exist, it shouldn't matter if the table is empty or not,
> > right?
> >>
> >> Thanks in advance,
> >> Jim
> >>
> >>
> >
> >
>
>
Re: RS.EOF RS.BOF
am 14.01.2005 19:38:38 von Jim in Arizona
I'm now using two pages to process this info and so far, it looks like I'm
doing ok with two.
Thanks for your help, Steve & Mark.
Jim
"Jim in Arizona" wrote in message
news:%23gAapml%23EHA.3328@TK2MSFTNGP10.phx.gbl...
> I'm having a little problem with conditioning formatting.
>
> This is a page that, when loaded, puts the
> Request.ServerVariables("AUTH_USER") into a variable. It then checks to
> see if that name has already been logged to a table in an access2000
> database. If it has, then they should get a message saying they've already
> voted. If not, then it should show a form where they can type in the name
> they're voting for, click the submit, and the vote be logged to a table,
> at the same time, the AUTH_USER is logged to a table so when they come
> back, they get the "you've alredy voted" message.
>
> I'm having problems with the BOF EOF condition formatting. I'm not sure
> how to do it properly. I've tried, but this is the error message I usually
> end up with:
>
> Error Type:
> ADODB.Field (0x800A0BCD)
> Either BOF or EOF is True, or the current record has been deleted.
> Requested operation requires a current record.
> /castvote.asp, line 43
>
> Here is my code:
>
> <%@ Language=VBScript %>
> <%
> OPTION EXPLICIT
>
> Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
>
> empname = Request.ServerVariables("AUTH_USER")
> votename = Request.Form("vote")
>
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> server.mappath("eoty.mdb")
>
> SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" & empname &
> "')"
> SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
> SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
>
> Set RS = Conn.Execute(SQL1,,1)
>
> Sub Vote
> If votename = "" Then
> formcode
> Response.Write "
You Must Type A Name"
> Else
> Conn.Execute SQL2,,1
> Conn.Execute SQL3,,1
> Response.Write "Thank You For Voting"
> End If
> End Sub
>
> Sub NoVote
> Response.Write "You've Already Voted"
> End Sub
>
> Sub formcode
> %>
>
> <%
> End Sub
>
> loggeduser = RS.Fields("voter")
> %>
> Cast Your Vote!
> <%
> If loggeduser = empname Then
> NoVote
> Else
> Vote
> End If
> %>
>
>
> Line 43 from the error message is loggeduser=RS.Fields("voter")
>
> I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm not
> sure what Im doing with it or how to properly use it.
> The table starts out empty but since the SQL statement is selecting a
> record that doesn't exist, it shouldn't matter if the table is empty or
> not, right?
>
> Thanks in advance,
> Jim
>
Re: RS.EOF RS.BOF
am 14.01.2005 19:49:12 von Steven Burn
Out of interest, why 2 pages?
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Jim in Arizona" wrote in message
news:eJ$Xhhm#EHA.2540@TK2MSFTNGP09.phx.gbl...
> I'm now using two pages to process this info and so far, it looks like I'm
> doing ok with two.
>
> Thanks for your help, Steve & Mark.
>
> Jim
>
>
> "Jim in Arizona" wrote in message
> news:%23gAapml%23EHA.3328@TK2MSFTNGP10.phx.gbl...
> > I'm having a little problem with conditioning formatting.
> >
> > This is a page that, when loaded, puts the
> > Request.ServerVariables("AUTH_USER") into a variable. It then checks to
> > see if that name has already been logged to a table in an access2000
> > database. If it has, then they should get a message saying they've
already
> > voted. If not, then it should show a form where they can type in the
name
> > they're voting for, click the submit, and the vote be logged to a table,
> > at the same time, the AUTH_USER is logged to a table so when they come
> > back, they get the "you've alredy voted" message.
> >
> > I'm having problems with the BOF EOF condition formatting. I'm not sure
> > how to do it properly. I've tried, but this is the error message I
usually
> > end up with:
> >
> > Error Type:
> > ADODB.Field (0x800A0BCD)
> > Either BOF or EOF is True, or the current record has been deleted.
> > Requested operation requires a current record.
> > /castvote.asp, line 43
> >
> > Here is my code:
> >
> > <%@ Language=VBScript %>
> > <%
> > OPTION EXPLICIT
> >
> > Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
> >
> > empname = Request.ServerVariables("AUTH_USER")
> > votename = Request.Form("vote")
> >
> > Set Conn = Server.CreateObject("ADODB.Connection")
> > Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> > server.mappath("eoty.mdb")
> >
> > SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" & empname
&
> > "')"
> > SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
> > SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
> >
> > Set RS = Conn.Execute(SQL1,,1)
> >
> > Sub Vote
> > If votename = "" Then
> > formcode
> > Response.Write "
You Must Type A Name"
> > Else
> > Conn.Execute SQL2,,1
> > Conn.Execute SQL3,,1
> > Response.Write "Thank You For Voting"
> > End If
> > End Sub
> >
> > Sub NoVote
> > Response.Write "You've Already Voted"
> > End Sub
> >
> > Sub formcode
> > %>
> >
> > <%
> > End Sub
> >
> > loggeduser = RS.Fields("voter")
> > %>
> > Cast Your Vote!
> > <%
> > If loggeduser = empname Then
> > NoVote
> > Else
> > Vote
> > End If
> > %>
> >
> >
> > Line 43 from the error message is loggeduser=RS.Fields("voter")
> >
> > I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm
not
> > sure what Im doing with it or how to properly use it.
> > The table starts out empty but since the SQL statement is selecting a
> > record that doesn't exist, it shouldn't matter if the table is empty or
> > not, right?
> >
> > Thanks in advance,
> > Jim
> >
>
>
Re: RS.EOF RS.BOF
am 14.01.2005 20:18:46 von Jim in Arizona
"Steven Burn" wrote in message
news:u3jUinm%23EHA.2596@tk2msftngp13.phx.gbl...
> Out of interest, why 2 pages?
Doing it on a single page has just been causing me a lot of frustration. For
some reason, things always work right the first time when I post data to an
asp page from a different page. Whenever I try posting data to itself, I run
into error after error and several hours of debugging and five posts to this
newsgroup (not that I mind asking).
Actually, my last problem was dealing with the initial load of the page and
the text field being empty. I couldn't seem to find a way around it.
My current project ivolves radio buttons so that's easy to deal with from
one page to another without having to worry about what happens if there is
no data. When I have more time for frustration, I'll get back to work on the
text field page posting back to itself properly and, of course, I'll be back
here with more questions.
In .NET, there's something called IsPostBack, I blieve that's what it was
called. YOu could do a condition like (iknow that isn't the syntax, I don't
have my book with me):
If page.ispostback then
Is there something similar in class asp?
Thanks,
Jim
>
> --
>
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "Jim in Arizona" wrote in message
> news:eJ$Xhhm#EHA.2540@TK2MSFTNGP09.phx.gbl...
>> I'm now using two pages to process this info and so far, it looks like
>> I'm
>> doing ok with two.
>>
>> Thanks for your help, Steve & Mark.
>>
>> Jim
>>
>>
>> "Jim in Arizona" wrote in message
>> news:%23gAapml%23EHA.3328@TK2MSFTNGP10.phx.gbl...
>> > I'm having a little problem with conditioning formatting.
>> >
>> > This is a page that, when loaded, puts the
>> > Request.ServerVariables("AUTH_USER") into a variable. It then checks to
>> > see if that name has already been logged to a table in an access2000
>> > database. If it has, then they should get a message saying they've
> already
>> > voted. If not, then it should show a form where they can type in the
> name
>> > they're voting for, click the submit, and the vote be logged to a
>> > table,
>> > at the same time, the AUTH_USER is logged to a table so when they come
>> > back, they get the "you've alredy voted" message.
>> >
>> > I'm having problems with the BOF EOF condition formatting. I'm not sure
>> > how to do it properly. I've tried, but this is the error message I
> usually
>> > end up with:
>> >
>> > Error Type:
>> > ADODB.Field (0x800A0BCD)
>> > Either BOF or EOF is True, or the current record has been deleted.
>> > Requested operation requires a current record.
>> > /castvote.asp, line 43
>> >
>> > Here is my code:
>> >
>> > <%@ Language=VBScript %>
>> > <%
>> > OPTION EXPLICIT
>> >
>> > Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
>> >
>> > empname = Request.ServerVariables("AUTH_USER")
>> > votename = Request.Form("vote")
>> >
>> > Set Conn = Server.CreateObject("ADODB.Connection")
>> > Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
>> > server.mappath("eoty.mdb")
>> >
>> > SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" &
>> > empname
> &
>> > "')"
>> > SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
>> > SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
>> >
>> > Set RS = Conn.Execute(SQL1,,1)
>> >
>> > Sub Vote
>> > If votename = "" Then
>> > formcode
>> > Response.Write "
You Must Type A Name"
>> > Else
>> > Conn.Execute SQL2,,1
>> > Conn.Execute SQL3,,1
>> > Response.Write "Thank You For Voting"
>> > End If
>> > End Sub
>> >
>> > Sub NoVote
>> > Response.Write "You've Already Voted"
>> > End Sub
>> >
>> > Sub formcode
>> > %>
>> >
>> > <%
>> > End Sub
>> >
>> > loggeduser = RS.Fields("voter")
>> > %>
>> > Cast Your Vote!
>> > <%
>> > If loggeduser = empname Then
>> > NoVote
>> > Else
>> > Vote
>> > End If
>> > %>
>> >
>> >
>> > Line 43 from the error message is loggeduser=RS.Fields("voter")
>> >
>> > I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm
> not
>> > sure what Im doing with it or how to properly use it.
>> > The table starts out empty but since the SQL statement is selecting a
>> > record that doesn't exist, it shouldn't matter if the table is empty or
>> > not, right?
>> >
>> > Thanks in advance,
>> > Jim
>> >
>>
>>
>
>
Re: RS.EOF RS.BOF
am 14.01.2005 20:20:30 von Jim in Arizona
"Mark Schupp" wrote in message
news:uOikCyl%23EHA.2076@TK2MSFTNGP15.phx.gbl...
> 1. protect yourself from embedded single quotes.
> SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" &
> Replace(empname, "'", "''") & "')"
>
> 2. if no record is found then you cannot access the data. Is EOF to
> determine if the user has voted.
>
> %>
>> Cast Your Vote!
>> <%
> Set RS = Conn.Execute(SQL1,,1)
> If rs.eof then
> NoVote
> Else
> Vote
> End If
>> %>
--SNIP--
I used your example on an identical project I just started on and it works
great. Thanks Mark.
Jim
Re: RS.EOF RS.BOF
am 14.01.2005 20:48:56 von Mark Schupp
Look at request.contentlength to determine if data has been posted.
--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Jim in Arizona" wrote in message
news:%23jEe83m%23EHA.4028@TK2MSFTNGP15.phx.gbl...
> "Steven Burn" wrote in message
> news:u3jUinm%23EHA.2596@tk2msftngp13.phx.gbl...
>> Out of interest, why 2 pages?
>
> Doing it on a single page has just been causing me a lot of frustration.
> For some reason, things always work right the first time when I post data
> to an asp page from a different page. Whenever I try posting data to
> itself, I run into error after error and several hours of debugging and
> five posts to this newsgroup (not that I mind asking).
>
> Actually, my last problem was dealing with the initial load of the page
> and the text field being empty. I couldn't seem to find a way around it.
>
> My current project ivolves radio buttons so that's easy to deal with from
> one page to another without having to worry about what happens if there is
> no data. When I have more time for frustration, I'll get back to work on
> the text field page posting back to itself properly and, of course, I'll
> be back here with more questions.
>
> In .NET, there's something called IsPostBack, I blieve that's what it was
> called. YOu could do a condition like (iknow that isn't the syntax, I
> don't have my book with me):
> If page.ispostback then
> Is there something similar in class asp?
>
> Thanks,
> Jim
>
>
>
>>
>> --
>>
>> Regards
>>
>> Steven Burn
>> Ur I.T. Mate Group
>> www.it-mate.co.uk
>>
>> Keeping it FREE!
>>
>> "Jim in Arizona" wrote in message
>> news:eJ$Xhhm#EHA.2540@TK2MSFTNGP09.phx.gbl...
>>> I'm now using two pages to process this info and so far, it looks like
>>> I'm
>>> doing ok with two.
>>>
>>> Thanks for your help, Steve & Mark.
>>>
>>> Jim
>>>
>>>
>>> "Jim in Arizona" wrote in message
>>> news:%23gAapml%23EHA.3328@TK2MSFTNGP10.phx.gbl...
>>> > I'm having a little problem with conditioning formatting.
>>> >
>>> > This is a page that, when loaded, puts the
>>> > Request.ServerVariables("AUTH_USER") into a variable. It then checks
>>> > to
>>> > see if that name has already been logged to a table in an access2000
>>> > database. If it has, then they should get a message saying they've
>> already
>>> > voted. If not, then it should show a form where they can type in the
>> name
>>> > they're voting for, click the submit, and the vote be logged to a
>>> > table,
>>> > at the same time, the AUTH_USER is logged to a table so when they come
>>> > back, they get the "you've alredy voted" message.
>>> >
>>> > I'm having problems with the BOF EOF condition formatting. I'm not
>>> > sure
>>> > how to do it properly. I've tried, but this is the error message I
>> usually
>>> > end up with:
>>> >
>>> > Error Type:
>>> > ADODB.Field (0x800A0BCD)
>>> > Either BOF or EOF is True, or the current record has been deleted.
>>> > Requested operation requires a current record.
>>> > /castvote.asp, line 43
>>> >
>>> > Here is my code:
>>> >
>>> > <%@ Language=VBScript %>
>>> > <%
>>> > OPTION EXPLICIT
>>> >
>>> > Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
>>> >
>>> > empname = Request.ServerVariables("AUTH_USER")
>>> > votename = Request.Form("vote")
>>> >
>>> > Set Conn = Server.CreateObject("ADODB.Connection")
>>> > Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
>>> > server.mappath("eoty.mdb")
>>> >
>>> > SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" &
>>> > empname
>> &
>>> > "')"
>>> > SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
>>> > SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
>>> >
>>> > Set RS = Conn.Execute(SQL1,,1)
>>> >
>>> > Sub Vote
>>> > If votename = "" Then
>>> > formcode
>>> > Response.Write "
You Must Type A Name"
>>> > Else
>>> > Conn.Execute SQL2,,1
>>> > Conn.Execute SQL3,,1
>>> > Response.Write "Thank You For Voting"
>>> > End If
>>> > End Sub
>>> >
>>> > Sub NoVote
>>> > Response.Write "You've Already Voted"
>>> > End Sub
>>> >
>>> > Sub formcode
>>> > %>
>>> >
>>> > <%
>>> > End Sub
>>> >
>>> > loggeduser = RS.Fields("voter")
>>> > %>
>>> > Cast Your Vote!
>>> > <%
>>> > If loggeduser = empname Then
>>> > NoVote
>>> > Else
>>> > Vote
>>> > End If
>>> > %>
>>> >
>>> >
>>> > Line 43 from the error message is loggeduser=RS.Fields("voter")
>>> >
>>> > I've tried doing an IF RS.EOF and RS.BOF = False Then statment but I'm
>> not
>>> > sure what Im doing with it or how to properly use it.
>>> > The table starts out empty but since the SQL statement is selecting a
>>> > record that doesn't exist, it shouldn't matter if the table is empty
>>> > or
>>> > not, right?
>>> >
>>> > Thanks in advance,
>>> > Jim
>>> >
>>>
>>>
>>
>>
>
>
Re: RS.EOF RS.BOF
am 14.01.2005 21:37:46 von Steven Burn
As Mark mentioned, you can use Request.ContentLength, or you can use a
querystring, or you can use a session variable;
e.g.
strTemp = Request.Querystring("bConfirm")
'// Check to make sure it's been posted
if Request.Form("SomeFormName")="" Then strTemp = ""
'// Check to make sure it was posted via your server
'// (not very reliable, but works to an extent)
if
Request.ServerVariables("HTTP_REFERER")<>request.servervariables("HTTP_HOST"
) & _
"\somepage.asp" Then strTemp = ""
Select Case lcase(strTemp)
Case "true"
'// Process your form
Case Else
'// Show your form
End If
Obviously you'd have to do some checking to make sure whomever hadn't
anticipated this and added the querystring value prior to coming to the
page, but this isn't hard.
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Jim in Arizona" wrote in message
news:#jEe83m#EHA.4028@TK2MSFTNGP15.phx.gbl...
> "Steven Burn" wrote in message
> news:u3jUinm%23EHA.2596@tk2msftngp13.phx.gbl...
> > Out of interest, why 2 pages?
>
> Doing it on a single page has just been causing me a lot of frustration.
For
> some reason, things always work right the first time when I post data to
an
> asp page from a different page. Whenever I try posting data to itself, I
run
> into error after error and several hours of debugging and five posts to
this
> newsgroup (not that I mind asking).
>
> Actually, my last problem was dealing with the initial load of the page
and
> the text field being empty. I couldn't seem to find a way around it.
>
> My current project ivolves radio buttons so that's easy to deal with from
> one page to another without having to worry about what happens if there is
> no data. When I have more time for frustration, I'll get back to work on
the
> text field page posting back to itself properly and, of course, I'll be
back
> here with more questions.
>
> In .NET, there's something called IsPostBack, I blieve that's what it was
> called. YOu could do a condition like (iknow that isn't the syntax, I
don't
> have my book with me):
> If page.ispostback then
> Is there something similar in class asp?
>
> Thanks,
> Jim
>
>
>
> >
> > --
> >
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "Jim in Arizona" wrote in message
> > news:eJ$Xhhm#EHA.2540@TK2MSFTNGP09.phx.gbl...
> >> I'm now using two pages to process this info and so far, it looks like
> >> I'm
> >> doing ok with two.
> >>
> >> Thanks for your help, Steve & Mark.
> >>
> >> Jim
> >>
> >>
> >> "Jim in Arizona" wrote in message
> >> news:%23gAapml%23EHA.3328@TK2MSFTNGP10.phx.gbl...
> >> > I'm having a little problem with conditioning formatting.
> >> >
> >> > This is a page that, when loaded, puts the
> >> > Request.ServerVariables("AUTH_USER") into a variable. It then checks
to
> >> > see if that name has already been logged to a table in an access2000
> >> > database. If it has, then they should get a message saying they've
> > already
> >> > voted. If not, then it should show a form where they can type in the
> > name
> >> > they're voting for, click the submit, and the vote be logged to a
> >> > table,
> >> > at the same time, the AUTH_USER is logged to a table so when they
come
> >> > back, they get the "you've alredy voted" message.
> >> >
> >> > I'm having problems with the BOF EOF condition formatting. I'm not
sure
> >> > how to do it properly. I've tried, but this is the error message I
> > usually
> >> > end up with:
> >> >
> >> > Error Type:
> >> > ADODB.Field (0x800A0BCD)
> >> > Either BOF or EOF is True, or the current record has been deleted.
> >> > Requested operation requires a current record.
> >> > /castvote.asp, line 43
> >> >
> >> > Here is my code:
> >> >
> >> > <%@ Language=VBScript %>
> >> > <%
> >> > OPTION EXPLICIT
> >> >
> >> > Dim empname, votename, loggeduser, RS, Conn, SQL1, SQL2, SQL3
> >> >
> >> > empname = Request.ServerVariables("AUTH_USER")
> >> > votename = Request.Form("vote")
> >> >
> >> > Set Conn = Server.CreateObject("ADODB.Connection")
> >> > Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> >> > server.mappath("eoty.mdb")
> >> >
> >> > SQL1 = "SELECT votingemp.voter from votingemp where(voter = '" &
> >> > empname
> > &
> >> > "')"
> >> > SQL2 = "INSERT INTO votingemp (voter) VALUES('" & empname & "')"
> >> > SQL3 = "INSERT INTO vote (employee) VALUES('" & votename & "')"
> >> >
> >> > Set RS = Conn.Execute(SQL1,,1)
> >> >
> >> > Sub Vote
> >> > If votename = "" Then
> >> > formcode
> >> > Response.Write "
You Must Type A Name"
> >> > Else
> >> > Conn.Execute SQL2,,1
> >> > Conn.Execute SQL3,,1
> >> > Response.Write "Thank You For Voting"
> >> > End If
> >> > End Sub
> >> >
> >> > Sub NoVote
> >> > Response.Write "You've Already Voted"
> >> > End Sub
> >> >
> >> > Sub formcode
> >> > %>
> >> >
> >> > <%
> >> > End Sub
> >> >
> >> > loggeduser = RS.Fields("voter")
> >> > %>
> >> > Cast Your Vote!
> >> > <%
> >> > If loggeduser = empname Then
> >> > NoVote
> >> > Else
> >> > Vote
> >> > End If
> >> > %>
> >> >
> >> >
> >> > Line 43 from the error message is loggeduser=RS.Fields("voter")
> >> >
> >> > I've tried doing an IF RS.EOF and RS.BOF = False Then statment but
I'm
> > not
> >> > sure what Im doing with it or how to properly use it.
> >> > The table starts out empty but since the SQL statement is selecting a
> >> > record that doesn't exist, it shouldn't matter if the table is empty
or
> >> > not, right?
> >> >
> >> > Thanks in advance,
> >> > Jim
> >> >
> >>
> >>
> >
> >
>
>
Re: RS.EOF RS.BOF
am 14.01.2005 21:55:50 von Jim in Arizona
"Steven Burn" wrote in message
news:u8jqMkn%23EHA.208@TK2MSFTNGP12.phx.gbl...
> As Mark mentioned, you can use Request.ContentLength, or you can use a
> querystring, or you can use a session variable;
Thanks Mark and Steve.
I couldn't find Request.ContentLength anywhere in the DevGuru ASP index:
http://www.devguru.com/Technologies/asp/quickref/asp_list.ht ml
Is that from a different version of ASP other than 3?
Re: RS.EOF RS.BOF
am 17.01.2005 18:43:07 von Mark Schupp
That's because I didn't check the docs first. You want request.totalbytes
instead.
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Jim in Arizona" wrote in message
news:ee1OMun%23EHA.1300@TK2MSFTNGP14.phx.gbl...
> "Steven Burn" wrote in message
> news:u8jqMkn%23EHA.208@TK2MSFTNGP12.phx.gbl...
> > As Mark mentioned, you can use Request.ContentLength, or you can use a
> > querystring, or you can use a session variable;
>
>
> Thanks Mark and Steve.
>
> I couldn't find Request.ContentLength anywhere in the DevGuru ASP index:
> http://www.devguru.com/Technologies/asp/quickref/asp_list.ht ml
>
> Is that from a different version of ASP other than 3?
>
>