Dim dbConn As ADODB.Connection
Dim Rst As ADODB.Recordset
Dim conString As String
conString = "Provider=sqloledb;Data Source=127.0.0.1;Initial Catalog =Northwind;User Id =sa;Password=coffee;"
Set dbConn = CreateObject("ADODB.Connection")
dbConn.ConnectionString = conString
dbConn.Open
Set Rst = CreateObject("ADODB.Recordset")
With Rst
.CursorLocation = adUseClient
.Open "select Distinct ShipCity from orders order by ShipCity asc", dbConn, adOpenForwardOnly, adLockReadOnly, adCmdText
End With
Dim i As Long
For i = 0 To Rst.RecordCount - 1
Combo1.AddItem Rst.Fields("ShipCity").Value
Rst.MoveNext
Next
Rst.Close
dbConn.Close
Set Rst = Nothing
Set dbConn = Nothing