473,405 Members | 2,185 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,405 software developers and data experts.

how to avoid either eof or bof error

chandru8
145 100+
ho to all
iam retrieving data from the access table when there is no data it saying either EOF or BoF true . how to avoid this.
If IsNull(rs.Fields(0)) = True Then

B = 1
Else
B = rs.Fields(0) + 1
End If

if there is no data b = 1 otherwise i need to increment that value B by 1
thanks to all
Feb 28 '08 #1
11 1786
Killer42
8,435 Expert 8TB
You could try checking .RecordCount first, before using the fields.
Feb 28 '08 #2
chandru8
145 100+
I Tried Record Count For Many Times But It Doesn't Work For Me .
Rs.recordcount Says -1
Is It Correct
Feb 28 '08 #3
debasisdas
8,127 Expert 4TB
That means your query is not fetching anything.
Feb 28 '08 #4
chandru8
145 100+
data present in the table also recordcount says -1 only and

for this condition

if isnull(rs.fields(0)) = false then

for the above condition if the table contain data or not it returns only false .
Feb 28 '08 #5
debasisdas
8,127 Expert 4TB
Try to execute your query in the backend and check if that returns any record or not .
Feb 28 '08 #6
VBWheaties
145 100+
The reason recordcount is -1 is because it has not traversed the set of records in the recordset. In other words, it doesn't know yet, how many records are in the recordset.

To get the record count:

Expand|Select|Wrap|Line Numbers
  1.  rs.Movelast
  2.  rs.Movefirst
  3.  Msgbox "There are " rs.RecordCount  & " records"
  4.  
However, this will be ineffective if there is no data.
The best way to check for no data is to check both BOF and EOF as they will be true if no data exists.

Expand|Select|Wrap|Line Numbers
  1. If ((rs.EOF) And (rs.BOF)) Then
  2.    Msgbox "no data"
  3. End If  
  4.  
Feb 28 '08 #7
dgzo
2
Trying
Expand|Select|Wrap|Line Numbers
  1. if not rs.eof then
  2. '...
  3. else
  4. '...
  5. end if
  6.  
could work also. So if your query does not return any records, the program does not execute what is inside the if part. And would not show any error.
Feb 28 '08 #8
Killer42
8,435 Expert 8TB
The reason recordcount is -1 is because it has not traversed ...
I just wanted to clarify this a bit, in case chandru8 didn't quite get it. When you first execute the query, the record count will be set to either 0 (no data) or 1 (some data). So you can use it as an indicator of whether something was found, but won't know the actual number of records until you go to the end of the recordset.

Very annoying, but it has been that way for a long time.
Feb 28 '08 #9
chandru8
145 100+
thanks to all for your reply
Hi Killer
I tried this one and i fixed the problem by creating a new table . i dont know for that particular table its not working
from the begining the record count is not working for me can you give me some example for that
instead of rs.recordcount i used select count(field name)

thanks.
Feb 29 '08 #10
I think there is no need for moving Records to get Record count. Refresh the recordset & then use RecordCount. I think it will work.
e.g.
rs.refresh
if rs.recordcount=0 then
.
.
Else
.
.
Endif
Feb 29 '08 #11
Killer42
8,435 Expert 8TB
Checking EOF and BOF is probably the better option, anyway.

I don't have any examples handy for recordcount, and don't actually do a lot of work with it. I just remember the problems with the records not being being until they're accessed.
Mar 2 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: SuryaPrakash Patel via SQLMonster.com | last post by:
Hello, There are three tables: OS-GroupOFCompanies (Table1) GoC_GroupOFCompaniesID (PK) OS-Organization (Table 2) Org_OrganizationID (PK)
14
by: Alexander Malkis | last post by:
A real-life example: int alpha_beta(unsigned depth,Position p, Move& m /*,other args*/) { //...do smth with p if(depth) { Move m; int val=alpha_beta(depth-1,p,m /*,other args*/); } //......
13
by: Steve Jorgensen | last post by:
== On Error Resume next, and Err.Number == If you want to call one of your procedures from another procedure, and check for errors afterward, you mayimagine that you should write code something...
32
by: KK | last post by:
Hello all, I have a unsigned char buffer 'buffer' and I need to convert the first 12 bytes of it into a string. Below is a code that should work, however, how can I avoid reinterpret_cast...
4
by: Bob Bedford | last post by:
Hello, I've a file wich must answer a request. For this my file must generate an XML output. That's work fine but sometimes I get a wrong mysql query. In this case, I've to manage the output...
6
by: betbubble | last post by:
I need help on two questions: 1. Is temp table the only way to pass recordsets from a nested stored procedure to a calling stored procedure? Can we avoid temp tables in this case? 2. Are...
7
by: amit.atray | last post by:
Environement : Sun OS + gnu tools + sun studio (dbx etc) having some Old C-Code (ansi + KR Style) and code inspection shows some big size variable (auto) allocated (on stack) say for ex. char...
9
by: Olaf | last post by:
Hi, here the following test code #include <iostream> using namespace std; struct Foo { Foo() { cout << " Foo()\n"; }
34
by: =?ISO-8859-1?Q?Marcel_M=FCller?= | last post by:
Hi, is there a way to avoid the automatic copy constructor generation. I do not want the object to be non-copyable. I simply do not want that copying is done by the default copy constructor. But...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.