我想把一个数据库里的一些数据比如城市地名(武汉,广州,青岛,上海)取出来放在COMBOBOX里的下拉框里,该怎么实现,谢谢
while not rs.eof
combobox.additems,,rs("City")
rs.movenext
wend
对不起,可能我说的不完全,数据是数据库里的一个字段,我这样写,没抱错,但是却不能实现.
Public Function queryempinfo(ByVal strsql As String) As Boolean
On Error GoTo on_queryerr
Set g_dbrct = Nothing
Call g_dbrct.Open(strsql, g_dbcon, adOpenDynamic, adLockOptimistic, -1)
queryempinfo = True
Exit Function
on_queryerr:
MsgBox "错误代码:" & Err.Number & vbCrLf & "错误描述:" & Err.Description, vbCritical + vbOKOnly, "错误"
queryempinfo = False
End Function
Private Sub Form_Load()
Dim intindex As Long
Dim strsql As String
strsql = "select * from publishlist"
If queryempinfo(strsql) = True Then
g_dbrct.MoveFirst
End If
For intindex = 0 To g_dbrct.RecordCount - 1
cmbloginname.AddItem Trim(g_dbrct.Fields("city").Value)
g_dbrct.MoveNext
Next intindex
有什么问题吗,谢谢