VB 怎麽把ACESS表裏的數據加載到ComboBOX控件裏面呢?
VB 怎麽把ACESS表裏的數據加載到ComboBOX控件裏面呢?
我用ADODC控件。
[解决办法]
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & "Data Source= " & App.Path & "\数据库名.mdb;;Persist Security Info=False; "
rst.Open "select id from 表名 ", cnn, adOpenForwardOnly, adLockReadOnly
Combo1.Clear
Do While Not rst.EOF
Combo1.AddItem rst.Fields(0)
Combo1.ItemData(Combo1.ListCount - 1) = rst.Fields(0)
rst.MoveNext
Loop
Combo1.ListIndex = -1