Code: Select all
Option Explicit
Private Sub test()
Dim DICT As Object
Dim Con As ADODB.Connection
Dim Cmd As New ADODB.Command
Dim Rs As ADODB.Recordset
Dim Rs1 As ADODB.Recordset
Dim SQL As String, RIGA As Long
Set DICT = New Dictionary
RIGA = 0
Set Con = New ADODB.Connection
Con.Open "provider=microsoft.jet.oledb.4.0;data source=C:\ASS_MF\BT\MAT.mdb"
Set Rs = New ADODB.Recordset
SQL = "SELECT ASS_MF_EC.RAPPORTO FROM ASS_MF_EC ORDER BY ASS_MF_EC.RAPPORTO"
Set Rs = Con.Execute(SQL)
While Not Rs.EOF
If DICT.Exists(Rs.Fields(0).Value) Then
MsgBox "already exists!"
Else
RIGA = RIGA + 1
DICT.Add RIGA, Rs.Fields(0).Value
End If
Rs.MoveNext
Wend
Set Rs = Nothing
Con.Close
Set Con = Nothing
End Sub