在开发VB+SQL SERVER数据库系统中怎么使用DATA控件,为了方便使用ListBox combobox,dblist, dbcombo

解决方案 »

  1.   

    用ADO 的话怎么使用DBCOMBO,DATABOMBO?
      

  2.   

    Public bb As Database
    dim aa as string
     ParkDB = App.Path & "\" & "数据库.MDB"
     Set bb = OpenDatabaseaa, False, False)
      

  3.   

    上楼使用的方法是DAO吧?
    我用的是MS SQL哦
      

  4.   

    如果我已经使用了ADO,现在我能用DBCOMBO吗?
    如:
    Dim Rs As ADODB.Recordset
     Set Rs = New ADODB.Recordset
      Sqlstr = "select Distinct 班级 from 学生表 "
      Rs.Open Sqlstr, Con
    我现在是要使用一个DBCOMBO控件显示所有的班级,怎么做?
      

  5.   

    我都使用combo控件来代替
    Option Explicit
    Private conn As ADODB.Connection
    Private rs As ADODB.RecordsetPrivate Sub Command1_Click()
    DataReport1.Show 1
    End SubPrivate Sub Form_Load()
    Dim apppath As String
    Dim DbFileName As String
    Dim ConnectString As String
    Dim i As Integer
    Set conn = New ADODB.Connection
    If Right(App.Path, 1) = "\" Then
                    apppath = App.Path
            Else
                    apppath = App.Path & "\"
    End If
    DbFileName = apppath & "article.mdb"
    ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
                    DbFileName & ";Persist Security Info=False;"
                    
                    On Error Resume Next
                    With conn
                            .CursorLocation = adUseClient
                            
                            .Open ConnectString
                    End With
                    Set rs = New ADODB.Recordset
    rs.Open "select id,mc from mz", conn, 1, 3
    If rs.EOF Then
    Exit Sub
    End IfFor i = 0 To rs.RecordCount - 1
    List1.AddItem rs.Fields("mc")
    List1.ItemData(i) = rs.Fields("id")
    rs.MoveNext
    NextEnd Sub
      

  6.   

    这个是不是要改一下?
    List1.AddItem rs.Fields("mc")
    'List1.ItemData(i) = rs.Fields("id")