Combo1中连接数据库后只能显示一个值。
 '让Combo1中显示数据库中的内容
  Set con = New ADODB.Connection
   strCon = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\db1.mdb"
   con.Open strCon
   strSql = "select * from gz"
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   Set rs = con.Execute(strSql)
   Combo1.Text = rs("gzname")        '只能显示一个选项
我的gzname字段中有很多数值,可是只显示第一个数值为什么呢,请帮忙看看,谢谢了!!~~~

解决方案 »

  1.   

    要用循环加入才行Set rs = con.Execute(strSql) 
    do until rs.eof
        combo1.additem rs("gzname")
        rs.MoveNext
    loop
      

  2.   

    你好 能具体说下怎么连接的数据库吗?
    谢谢
    我是这样连接的可是出现了错误
    是mysql
    Public ConnStr As String
    Public scon As ADODB.Connection
    Public rs As ADODB.RecordsetPrivate Sub Command1_Click()Dim strconnectionstring As String
    user = root
    password = 123456
    Private Sub Form_Load()
              Set scon = New ADODB.Connection
              strconnectionstring = "Provider=SQLOLEDB.1;User ID=user;Password=password;Persist Security Info=False;Network Library=dbmssocn;Initial Catalog=Shop;Data Source=127.0.0.1"
              scon.ConnectionTimeout = 1
              scon.CursorLocation = adUseClient
              scon.ConnectionString = strconnectionstring
              scon.Open
              If scon.State = 1 Then
                      MsgBox "ok"
              Else
                      Err.Clear
                      MsgBox "No"
              End If
      
               
    End Sub
      

  3.   

    3楼的,连接数据库的字符串好像有错strconnectionstring = "Provider=SQLOLEDB.1;User ID="&user&";Password="&password&";Persist Security Info=False;Network Library=dbmssocn;Initial Catalog=Shop;Data Source=127.0.0.1"