-1
У меня есть имя поля со списком cbSectionКак заполнить данные в поле со списком из SQL-сервера
как я могу заселить данные из SQL-сервера в поле со списком?
Любая идея поможет
-Спасибо
У меня есть имя поля со списком cbSectionКак заполнить данные в поле со списком из SQL-сервера
как я могу заселить данные из SQL-сервера в поле со списком?
Любая идея поможет
-Спасибо
Это прямо из VbForums (я не несу кредит для кода!), Первый результат для быстрого поиска Google.
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