Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADO Problem
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00593405
Message ID:
00593425
Vues:
23
Don't use a command object for a simple query like this:
Public function GetNextRecordId As Integer

Dim iRetVal As Integer

Set oRecSet = New ADODB.Recordset
oRecSet.open "select recordid from members", oConn, adOpenStatic, adLockReadOnly


oRecSet.MoveLast
iRetVal = oRecSet.Fields("RecordId").Value + 1

GetNextRecordId = iRetVal
>In the following function, I'm getting the error:
>"Rowset does not support fetching backward"
>
>on the line with oRecSet.MoveLast
>
>I'm using Microsoft Jet OLEDB 3.51 as a provider, and the
>recordset cursortype is adOpenKeyset.
>
>
>Public function GetNextRecordId As Integer
>
>Dim iRetVal As Integer
>
>Set oSqlCmd = New ADODB.Command
>oSqlCmd.ActiveConnection = oConn
>oSqlCmd.CommandType = adCmdText
>oSqlCmd.CommandText = "select recordid from members"
>
>Set oRecSet = New ADODB.Recordset
>Set oRecSet = oSqlCmd.Execute
>
>oRecSet.MoveLast
>iRetVal = oRecSet.Fields("RecordId").Value + 1
>
>GetNextRecordId = iRetVal
>
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform