Vb6 如何从sql server填充组合框中的数据
我有一个组合框名cbSection 如何在组合框中填充来自sql server的数据 任何想法都会有帮助 -谢谢,这是谷歌快速搜索的第一个结果Vb6 如何从sql server填充组合框中的数据,vb6,Vb6,我有一个组合框名cbSection 如何在组合框中填充来自sql server的数据 任何想法都会有帮助 -谢谢,这是谷歌快速搜索的第一个结果 Dim strSQL as String 'Declare the variables we need Dim oRS as ADODB.Recordset Set oRS = New ADODB.Recordset 'Load the data '** change this SQL
Dim strSQL as String 'Declare the variables we need
Dim oRS as ADODB.Recordset
Set oRS = New ADODB.Recordset
'Load the data
'** change this SQL to load the data you want.
strSQL = "SELECT Colour FROM Colours"
'** change oConn to the name of your Connection object
oRS.Open strSQL, oConn, adOpenForwardOnly, adLockReadOnly, adCmdText
'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With cboColour
.Clear
Do While Not oRS.EOF
'** change the name of the field here to the one you want to show
.AddItem oRS.fields("Colour").value
oRS.MoveNext
Loop
End With
'Tidy up
oRS.Close
Set oRS = Nothing