2012年11月4日 星期日

vb6 ADODB 運用


Dim oDb As New ADODB.Connection
Dim oRS As New ADODB.Recordset
Dim sSql As String

oDb.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
      & "Data Source=C:\Data\MyAccessDB.mdb;Jet"
sSql = "SELECT DISTINCT([LastName]) FROM [Authors] ORDER BY LastName ASC"


oRS.Open sSql, oDB, adOpenForwardOnly, adLockReadOnly

Do While not oRS.EOF
    With cboMyCombo
        .AddItem trim$(oRS("LastName").Value)
    End With
    oRS.MoveNext
Loop
oRS.Close
oDB.Close

Set oRS = Nothing
Set oDB = Nothing

沒有留言:

張貼留言