Re: VB-Script Counts of Recordsets ADODB MS Access



Uwe Wiards wrote:
Hello,

i´m trying to read in VB-Script datas from a MS-Access database,
but... Into the table "Bestelldaten" are four test records, but
.recordcount told me "-1"

System: MS-XP and MS-Access 2002 SP3

Where are my mistakes?

SQL = "SELECT Bestelldaten.Nummer FROM Bestelldaten;"
strPfadDB = "c:\Testdb.mdb"
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" &
strPfadDB
Set Conn = CreateObject("ADODB.Connection")
Set Cmd = CreateObject("ADODB.Command")

conn.open strConn

cmd.ActiveConnection = conn

cmd.commandText=SQL

Set rs=CMD.Execute

If Not rs.EOF And Not rs.BOF Then
Msgbox "Count= " & rs.recordcount
Else

End If


Thanks an best regards

You need to use a different cursor type from the default read-only
forward-only cursor that does not support bookmarks or record count.
The easiest change is to change the cursor location of the recordset from
the default server-side cursor to a client-side cursor, because a
client-side cursor can only be a static cursor which does support bookmarks
and provides an immediate record count without moving to the last record.
There are two ways to change the cursor location:
1. change the connection object's CursorLocation property to adUseClient
before opening the recordset. This will cause the recordset to default to
client-side.
2. explicitly create the recordset object rather than using a variant
variable (rs), set its CursorLocation property to adUseClient, and use the
recordset's Open method to open it rather than the Command object's Execute
method.

In your particular situation, I would prefer method 1, since the explicit
Command object is not needed, given that you can use the Connection object's
Execute method instead:

conn.CursorLocation=3 'adUseClient
conn.open strConn
Set rs = conn.Execute(SQL,,1)




.



Relevant Pages

  • Re: Gebundene Controls aus ADO-Recordset aktualisieren
    ... Engpass ist vor allem das LAN und der Server selbst. ... ob man mit einem SQL-Server oder der Jet-Engine ... Cursor und statischen Recordsets, egal welches Datenbanksystem ... dass eine Bewegung im Recordset eben auch ...
    (microsoft.public.de.vb.datenbank)
  • Re: Gebundene Controls aus ADO-Recordset aktualisieren
    ... Wozu ein serverseitiger Cursor? ... Ich kann also z.B. bei adOpenKeyset im Programmcode ... CursorLocation adUseServer bei Access sinnlos, ... wenn Du in Deinem Recordset zu einem anderen ...
    (microsoft.public.de.vb.datenbank)
  • Re: Suche mit SEEK
    ... ein Recordset mit serverseitigem Cursor ... Das heisst also es muss ein Recordset mit serverseitigem Cursor ... clientseitigem Cursor arbeiten und die Suche nach einem bestimmten Datensatz ...
    (microsoft.public.de.vb.datenbank)
  • Re: client-side versus server-side cursor
    ... It happens because in a case of client-side cursor provider transfers all ... In a case of server-side cursor, provider opens cursor, ... CommandTimeout property of the recordset to bigger value ...
    (microsoft.public.data.ado)
  • Re: How to summarize recordset...Select Distinct alternative?
    ... functionality to store a set of paired values ... then the recordset is copied into local ... ADO provides a Cursor Library that provides the cursor ... reconnected to the database simply by setting the ActiveConnection to an ...
    (microsoft.public.data.ado)