By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,625 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,625 IT Pros & Developers. It's quick & easy.

IF Not Then response.write query help

P: n/a
Hi All,

having a problem with the error "Either BOF or EOF is True, or the current
record has been deleted. " found a workaround that allows the non existent
data to be bypassed and insert a 0 value into the textfield and inserted
into the table, however if the record does exist it still shows the 0 value?
I want it to Response.Write the recordset value entry.

At present
<input name="BroughtForward" type="hidden" id="BroughtForward" value="<% If
Not rsDriverPayments.EOF OR rsDriverPayments.BOF Then Response.Write "0" END
If %">

I would like it to work like

<input name="BroughtForward" type="hidden" id="BroughtForward" value="<% If
Not rsDriverPayments.EOF OR rsDriverPayments.BOF Then Response.Write "0"
ELSE Response.Write rsDriverPayments.Fields.Item("BroughtForward").Val ue END
If %">
Simon Gare
The Gare Group Limited

website: www.thegaregroup.co.uk
website: www.privatehiresolutions.co.uk
Jan 9 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Simon Gare" <sg@simongare.comwrote in message
news:eD**************@TK2MSFTNGP06.phx.gbl...
Hi All,

having a problem with the error "Either BOF or EOF is True, or the current
record has been deleted. " found a workaround that allows the non existent
data to be bypassed and insert a 0 value into the textfield and inserted
into the table, however if the record does exist it still shows the 0
value?
I want it to Response.Write the recordset value entry.

At present
<input name="BroughtForward" type="hidden" id="BroughtForward" value="<%
If
Not rsDriverPayments.EOF OR rsDriverPayments.BOF Then Response.Write "0"
END
If %">

I would like it to work like

<input name="BroughtForward" type="hidden" id="BroughtForward" value="<%
If
Not rsDriverPayments.EOF OR rsDriverPayments.BOF Then Response.Write "0"
ELSE Response.Write rsDriverPayments.Fields.Item("BroughtForward").Val ue
END
If %">
You are telling it to show 0 if your recordset is NOT End Of File, and to
write a non-existent record if it is:

If Not rsDriverPayments.EOF OR rsDriverPayments.BOF Then
'This line detects that there are records available
Response.Write "0"
ELSE 'if rsDriverPayments is EOF or rsDriverPayments is BOF
Response.Write rsDriverPayments.Fields.Item("BroughtForward").Val ue
' if it's EOF or BOF, there are no records to write
END If
You should be doing it the other way round:

If Not rsDriverPayments.EOF Then
Response.Write rsDriverPayments("BroughtForward")
Else
Response.Write "0"
End IF

Incidentally, the full test for a populated recordset should be:

If NOT rs.EOF Or NOT rs.BOF

In other words, there should be a NOT in front of both EOF and BOF. Also, I
seem to recall from a previous post by Bob Barrows that the test for BOF is
unnecessary when using a default forward-only cursor, so only testing for
EOF is needed in 99% of cases. I'm sure he will correct me if I got that
wrong :-)

--
Mike Brind
Jan 9 '07 #2

P: n/a
Mike wrote:
>
Incidentally, the full test for a populated recordset should be:

If NOT rs.EOF Or NOT rs.BOF

In other words, there should be a NOT in front of both EOF and BOF. Also,
I seem to recall from a previous post by Bob Barrows that the
test for BOF is unnecessary when using a default forward-only cursor,
so only testing for EOF is needed in 99% of cases. I'm sure he will
correct me if I got that wrong :-)
Well, since you called ...
If a recordset contains any records at all, it will always be "ponting" at
the first record when the recordset is opened. So only one of the properties
(EOF, BOF) needs to be tested immediately after opening the recordset. It
really does not matter which one you test (BOF or EOF), but I typically
choose EOF because ... well, .. for absolutely no good reason. It just
sounds better to me.

BOF can only be true if you make an attempt to MoveFirst or MovePrevious,
so, as you say, with a forward-only cursor, BOF will probably never be true,
unless you start playing with the Cachesize property. If more than one
record is in the cache, backward navigation will be possible even with a
forward-only cursor. The "forward-only" relates to how the records are
retrieved from the server-side cursor.

Once navigation has been done through a recordset, or records have been
deleted from it, then both BOF and EOF need to be tested to determine if it
is empty.

For the OP: you should study the terms I've mentioned in the ADO
documentation which is available here:
http://msdn.microsoft.com/library/en...ireference.asp

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jan 9 '07 #3

P: n/a
Thanks guys works perfectly.

Regards
Simon
"Mike" <in*****@invalid.comwrote in message
news:uX**************@TK2MSFTNGP06.phx.gbl...
>
"Simon Gare" <sg@simongare.comwrote in message
news:eD**************@TK2MSFTNGP06.phx.gbl...
Hi All,

having a problem with the error "Either BOF or EOF is True, or the
current
record has been deleted. " found a workaround that allows the non
existent
data to be bypassed and insert a 0 value into the textfield and inserted
into the table, however if the record does exist it still shows the 0
value?
I want it to Response.Write the recordset value entry.

At present
<input name="BroughtForward" type="hidden" id="BroughtForward" value="<%
If
Not rsDriverPayments.EOF OR rsDriverPayments.BOF Then Response.Write "0"
END
If %">

I would like it to work like

<input name="BroughtForward" type="hidden" id="BroughtForward" value="<%
If
Not rsDriverPayments.EOF OR rsDriverPayments.BOF Then Response.Write "0"
ELSE Response.Write rsDriverPayments.Fields.Item("BroughtForward").Val ue
END
If %">

You are telling it to show 0 if your recordset is NOT End Of File, and to
write a non-existent record if it is:

If Not rsDriverPayments.EOF OR rsDriverPayments.BOF Then
'This line detects that there are records available
Response.Write "0"
ELSE 'if rsDriverPayments is EOF or rsDriverPayments is BOF
Response.Write rsDriverPayments.Fields.Item("BroughtForward").Val ue
' if it's EOF or BOF, there are no records to write
END If
You should be doing it the other way round:

If Not rsDriverPayments.EOF Then
Response.Write rsDriverPayments("BroughtForward")
Else
Response.Write "0"
End IF

Incidentally, the full test for a populated recordset should be:

If NOT rs.EOF Or NOT rs.BOF

In other words, there should be a NOT in front of both EOF and BOF. Also,
I
seem to recall from a previous post by Bob Barrows that the test for BOF
is
unnecessary when using a default forward-only cursor, so only testing for
EOF is needed in 99% of cases. I'm sure he will correct me if I got that
wrong :-)

--
Mike Brind


Jan 9 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.