Re: ADO recordset returns -1
From: Harald Staff (innocent_at_enron.invalid)
Date: 08/15/04
- Next message: Harald Staff: "Re: Three short questions regarding importing of data. See code"
- Previous message: Susan Hayes: "Three short questions regarding importing of data. See code"
- In reply to: Dennis: "ADO recordset returns -1"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: ADO recordset returns -1"
- Reply: anonymous_at_discussions.microsoft.com: "Re: ADO recordset returns -1"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 15 Aug 2004 10:33:13 +0200
Hi Dennis
Recordsets comes with different "cursors". Some let you browse back and
forth, some are "forward only" (faster but no recordcount or moves except
movenext and movelast). It seems that default is forwardonly from what you
report here. Try
rsData.Open sSQL, myConnection, adopenkeyset, adopenreadonly
The speed issue between forwardonly and keyset depends on database brand and
size. For smaller Access apps I don't notice much difference, Oracle
likewise, but SQLserver is annoyingly slow using keyset. My personal
undocumented experiences only.
HTH. Best wishes Harald
"Dennis" <dennisbrininger@comcast.net> skrev i melding
news:60e401c48282$d181f190$a301280a@phx.gbl...
> I have a connection to the Northwind database from
> Excel. My queries work find except when I request the
> number of records I always get -1. Is there something
> I'm missing? Here's a section of my code if this helps:
>
> Thank you in advance, Dennis
>
> *************start code****************
>
> Dim myConnection As String
> Dim rsData As ADODB.Recordset
>
> '===================================
> 'Create a connection to Northwind DB
> '===================================
> myConnection = "Provider=Microsoft.jet.oledb.4.0;" & _
> "Data
> source=C:\ProgramFiles\Microsoftoffice\" & _
> "Office10
> \Samples\Northwind.mdb;"
>
> sSQL = "SELECT * FROM Categories"
> Set rsData = New ADODB.Recordset
> rsData.Open sSQL, myConnection
> MsgBox rsData.RecordCount
>
> ************end code*****************
- Next message: Harald Staff: "Re: Three short questions regarding importing of data. See code"
- Previous message: Susan Hayes: "Three short questions regarding importing of data. See code"
- In reply to: Dennis: "ADO recordset returns -1"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: ADO recordset returns -1"
- Reply: anonymous_at_discussions.microsoft.com: "Re: ADO recordset returns -1"
- Messages sorted by: [ date ] [ thread ]