473,503 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADO recordset problem

Hi

I'm using the following code to retrieve some data from a seperate DB:

Dim con As New ADODB.Connection

con.Open _
"Provider=Microsoft.jet.oledb.4.0; Data Source=\
\feltfps0002\gengrpshare0009\SMP\CONFIDENTIAL\Prog ramme office\PIP
\PIP.mdb"

sql07 = "select * from qryBBLatestDates Where LatestViewDate
between #04/01/2007# and #03/31/2008# and Type_of_site = " &
"""Extension""" & ""

rstYear07.Open sql07, con, adOpenForwardOnly, adLockReadOnly

If rstYear07.RecordCount 0 Then
rstYear07.MoveFirst
Do While Not rstYear07.EOF

..........
However, it wont seem to retrieve the data, as the recordcount is
always -1. Ive pasted the code into a query and it does pull out of a
number of records so i cant figure out where im going wrong. Any
ideas?

Thanks for any suggestions

Paul

Nov 7 '07 #1
2 1762
"pa************@hotmail.com" <pa************@hotmail.comwrote in
news:11**********************@k79g2000hse.googlegr oups.com:
If rstYear07.RecordCount 0 Then
rstYear07.MoveFirst
From ADO help:

"The cursor type of the Recordset object affects whether the number of
records can be determined. The RecordCount property will return -1 for a
forward-only cursor; the actual count for a static or keyset cursor; and
either -1 or the actual count for a dynamic cursor, depending on the data
source."

The default cursor type is adOpenForwardOnly.

You could change the cursor type to
adOpenKeyset
adOpenDynamic
or
adOpenStatic
with rstYear07.Open sql07, con, adOpenSomethingElse, adLockReadOnly

and you may need to for other reasons, but if you just want to move through
the recordset you could just remove the two lines
If rstYear07.RecordCount 0 Then
rstYear07.MoveFirst
(and the corresponding EndIf)

They are are redundant.

--
lyle fairfield
Nov 7 '07 #2

Thanks Lyle, problem solved!
On 7 Nov, 11:14, lyle fairfield <lylef...@yahoo.cawrote:
"paulquinlan...@hotmail.com" <paulquinlan...@hotmail.comwrote innews:11**********************@k79g2000hse.google groups.com:
If rstYear07.RecordCount 0 Then
rstYear07.MoveFirst

From ADO help:

"The cursor type of the Recordset object affects whether the number of
records can be determined. The RecordCount property will return -1 for a
forward-only cursor; the actual count for a static or keyset cursor; and
either -1 or the actual count for a dynamic cursor, depending on the data
source."

The default cursor type is adOpenForwardOnly.

You could change the cursor type to
adOpenKeyset
adOpenDynamic
or
adOpenStatic
with rstYear07.Open sql07, con, adOpenSomethingElse, adLockReadOnly

and you may need to for other reasons, but if you just want to move through
the recordset you could just remove the two lines
If rstYear07.RecordCount 0 Then
rstYear07.MoveFirst

(and the corresponding EndIf)

They are are redundant.

--
lyle fairfield
Nov 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1949
by: gary artim | last post by:
Hi All, I have a problem using DBIx::RecordSet. I get correct results but continue to get these messages on stderr. I looked at Compat.pm and it seems to be pointing out a problem with my call...
0
1520
by: belacyrf | last post by:
Here's the code: ------------------------------------------------------------------- accessID = request("accessID") strSQL = "SELECT * From PendingAccRequests Where AccessID = "&accessID ...
4
5694
by: Gerry Abbott | last post by:
Hi all. I wish to call a recordset from a function. Ive tried the following approach, -------------------------------------------------------- Function PassRS() As Recordset Dim db As...
6
6489
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
36
4413
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
5
2495
by: zMisc | last post by:
Are there any tricks in updaitng a JOINed recordset? I joned to tables and when I try to change a field on the recordset and update it, I get this error: "Unknown column 'CCDE' in 'where...
5
5873
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
0
1530
by: PCroser | last post by:
I have encountered a problem when querying a table. The query passed data into a recordset which should have resulted in many records but has returned EOF. After debugging the code the only...
0
3112
by: Yarik | last post by:
Hello, Here is a sample (and very simple) code that binds an Access 2003 form to a fabricated ADO recordset: ' Create recordset... Dim rs As ADODB.Recordset: Set rs = New ADODB.Recordset '...
2
5494
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7271
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
7319
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...
1
6979
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...
1
4998
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...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.