|
 |
asp_databases thread: My Logic
Message #1 by Leo Clayton <claytonl@z...> on Wed, 13 Sep 2000 15:50:31 -0400
|
|
--=====================_103214434==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
The following is some ASP code that I wrote:
EMPLOYEE MASTER DATABASE
EMPLOYEE SKILL SELECTION
In order to GENERATE A SKILLS RECORD in the EMPLOYEE SKILLS TABLE "
Response.Write "
" Response.Write "YOU MUST CHECK AN INDIVIDUAL SKILL FOR EACH ENTRY"
Response.Write "
" Response.Write "YOU WANT IN THE TABLE " %>
What I am trying to do is read a table in a database and print out the
contents is a 3-column html table. I looked at the results in my browser
and the only thing that appears is the headings and text before I go into
my "Do While Loop". I look in View Page Source and it was reading the table
correctly, but for some reason I am trying to read pass EOF. The actual
last record and the resultant errors are below: RDBMS
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted; the
operation requested by the application requires a current record.
/EmployeeMasterStuff/SelectingSkills2.asp, line 44 . Would you please tell
me what I am doing wrong and steer me in the right direction.
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 14 Sep 2000 12:16:56 +1000
|
|
The error is in this part:
<% WHILE NOT oRs.EOF %>
<TR>
<TD><INPUT TYPE="CHECKBOX" NAME="SKILL"></TD>
<TD> <% =oRs.Fields("SkillName").Value %></TD>
<% oRs.MoveNext %>
<TD><INPUT TYPE="CHECKBOX" NAME="SKILL"></TD>
<TD> <% =oRs.Fields("SkillName").Value %></TD>
<% oRs.MoveNext %>
<TD><INPUT TYPE="CHECKBOX" NAME="SKILL"></TD>
<TD> <% =oRs.Fields("SkillName").Value %></TD>
</TR>
<% WEND %>
You are moving through the recordset three times in each loop, but you are
only checking for .EOF at the top of each look (the While NOT oRS.EOF).
You need to do it like this:
<%
Do while not objRS.EOF
Response.Write( _
"<tr>" & vbCrLf)
For i = 1 to 3
If not objRS.EOF then
Response.Write( _
"<td><input type="checkbox" name="skill"></td>" & vbCrLf & _
"<td> " & oRs.Fields("SkillName").Value & "</td>"
& vbCrLf)
Else
Response.Write( _
"<td> </td>" & vbCrLf & _
"<td> </td>" & vbCrLf)
End if
Next
Response.Write( _
"</tr>" & vbCrLf)
Loop
%>
This code checks for .EOF before you write out each record. It also checks
to see if you are .EOF before starting each loop.
Another thing I noticed is tat you are not allocating any value to each of
the <input> fields. Isn't this going to cause a problem later?
Cheers
Ken
Message #3 by Chris Neale <Chris.Neale@s...> on Thu, 14 Sep 2000 08:20:33 +0100
|
|
The problem is that you are trying to display 3 records per field, and you
don't give the script any opportunity to stop if there aren't 3 records. For
example, imagine you have 5 records. The first loop of the while...wend will
be fine, no problems. But the second time it goes through there'll only be 2
records. You've said 'print record, print record, print record', but there
are only 2 records. Hence the ADODB error on the third print.
Try putting an if...end inside your while...wend loop. Something like 'if
not oRS.EOF then; print; end if;', that way, should the records run out half
way through the loop it won't try to print things that aren't there.
Chris
Chaos! Panic! Disaster! (My work here is done)
Chris Neale. Web/Wap Developer
Chris.neale@s... <mailto:Chris.neale@s...>
www.sparkresponse.co.uk
-----Original Message-----
From: Leo Clayton [SMTP:claytonl@z...]
Sent: Wednesday, September 13, 2000 8:51 PM
To: ASP Databases
Subject: [asp_databases] My Logic
The following is some ASP code that I wrote:
EMPLOYEE MASTER DATABASE
EMPLOYEE SKILL SELECTION
<% Response.Write "In order to GENERATE A SKILLS RECORD in the
EMPLOYEE SKILLS TABLE " Response.Write "
" Response.Write "YOU MUST CHECK AN INDIVIDUAL SKILL FOR EACH ENTRY"
Response.Write "
" Response.Write "YOU WANT IN THE TABLE " %>
<% strSQL = "SELECT * FROM SkillsTable;" Set DbObj
Server.CreateObject("ADODB.CONNECTION") DbObj.Open "DSN=EmployeeMaster" Set
oRs = DbObj.Execute(strSQL) %>
<% WHILE NOT oRs.EOF %>
<% =oRs.Fields("SkillName").Value %> <% oRs.MoveNext %>
<% =oRs.Fields("SkillName").Value %> <% oRs.MoveNext %> <%
=oRs.Fields("SkillName").Value %>
<% WEND %>
<% 'now clean up and close DbObj.Close Set DbObj = Nothing %>
---
You are currently subscribed to asp_databases
$subst('Email.Unsub')
What I am trying to do is read a table in a database and print out
the contents is a 3-column html table. I looked at the results in my browser
and the only thing that appears is the headings and text before I go into my
"Do While Loop". I look in View Page Source and it was reading the table
correctly, but for some reason I am trying to read pass EOF. The actual last
record and the resultant errors are below: RDBMS
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted;
the operation requested by the application requires a current record.
/EmployeeMasterStuff/SelectingSkills2.asp, line 44 . Would you
please tell me what I am doing wrong and steer me in the right direction.
|
|
 |