Bonjour,

En me connectant à une table via ADODB, je souhaite me servir du RecordCount pour générer mon nouveau numéro de ligne mais celui-ci me renvoit systématiquement la valeur -1 (table vide ?).

Pouvez-vous m'éclairer ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 
        Dim cnx As ADODB.Connection
        Dim MonRst As ADODB.Recordset
 
        cnx = New ADODB.Connection
        MonRst = New ADODB.Recordset
 
        cnx.Provider = "Microsoft.ACE.OLEDB.12.0"
        cnx.ConnectionString = "Data Source=C:\TEST DB.accdb"
        cnx.Open()
 
        MonRst.Open("SELECT * From Table1", cnx, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic)
 
        Dim x As Integer = MonRst.RecordCount
 
        MsgBox(x)