473,385 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

IF Not Then response.write query help

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
3 14003

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob McLennan - ZETLAND | last post by:
Hi, I'm relatively clueless when it comes to correct ASP syntax. I'm testing out a search form for my company's website which is done in ASP. The results are displayed as per the code shown at the...
7
by: Carol | last post by:
I need to put this whole line into a response.write statement: field delimiter = "\"" how?
14
by: Hugh Welford | last post by:
Hi - trying to display a memo field using response.write but it truncates it. Is there a size issue with response.write? If so how do I get round it and to be able to display the whole memo field ...
4
by: Martin Feuersteiner | last post by:
Dear Group I'm new to http responses / requests and would be grateful if you can shed some light on this issue. Let's assume I've two pages, a.aspx and b.aspx. The buffer is set to false for...
2
by: Jack | last post by:
Hi, I have a asp page. This page pulls all data from a query. Part of the code is as follows: <% Response.Write "<table border='1' width='80%' height='1' cellspacing='1' >" Response.Write...
4
by: Erland | last post by:
Hi , I am using Asp.net 1.1 using VB.NET and in the Page_Load() method I am trying to use a Response.Write method as following but I keep getting errors, --------------------------...
15
by: Simon Gare | last post by:
Hi, trying to retrieve postal codes from the db but only want the query to look at the first 3 digits of the code tried using (LEFT(dbo.booking_form.COLL_POST_CODE),3) but that doesn't work. I...
4
by: myth0s | last post by:
(After thinking about it, maybe this should have been posted in the .NET forum...) Hi, I have a stored procedure in SQL Server that sends me a 3000+ char pre-formatted XML string. I use "FOR...
5
by: satyabhaskar | last post by:
hi all, In my web page i have created radio buttons dynamically on to the page .....following is my code string Course, Semester, Section; int rowsCount; string con =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.