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
If %> ">
I would like it to work like
ELSE Response.Write rsDriverPayments.Fields.Item("BroughtForward").Value END
If %> ">
"Simon Gare" wrote in message
news:eDecgl5MHHA.3944@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
>
> END
> If %> ">
>
> I would like it to work like
>
>
> ELSE Response.Write rsDriverPayments.Fields.Item("BroughtForward").Value
> 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").Value
' 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
Re: IF Not Then response.write query help
am 09.01.2007 13:03:58 von reb01501
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-us/ado270/htm/mdmscadoa pireference.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"
Re: IF Not Then response.write query help
am 09.01.2007 16:46:06 von Simon Gare
Thanks guys works perfectly.
Regards
Simon
"Mike" wrote in message
news:uXKR4V8MHHA.3872@TK2MSFTNGP06.phx.gbl...
>
> "Simon Gare" wrote in message
> news:eDecgl5MHHA.3944@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
> >
> > END
> > If %> ">
> >
> > I would like it to work like
> >
> >
> > ELSE Response.Write rsDriverPayments.Fields.Item("BroughtForward").Value
> > 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").Value
> ' 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
>
>