1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Dim cn As ADODB.Connection
Set cn = New Connection
'Pour une BD en format 2003 .mbd
'cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\donnees.mdb"
'Pour une BD en format 2007 .accbd
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\donnees.accdb"
cn.Open
Dim rs As ADODB.Recordset
Set rs = New Recordset
rs.Open "SELECT prenom,nom FROM personnes", cn, adOpenDynamic, adLockOptimistic
While rs.EOF = False
List1.AddItem rs!prenom + " " + rs!nom
rs.MoveNext
Wend
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing |
Partager