Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql As String
Set cnn = New ADODB.Connection
cnn.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=你的数据库名"
sql = "select*from 你的表名"
Set rs = New ADODB.Recordset
rs.Open sql, cnn, adOpenKeyset, adLockOptimistic当然前提是将ADO放到当前窗体中啊

解决方案 »

  1.   

    1 先在"工程"-"引用"中,选择
         “Microsoft ActiveX Data Objects Recordset 2.5 Library”
    2 用楼上的办法就OK.
      

  2.   

    另外在:cnn.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=‘路径+你的数据库名’"
      

  3.   

    先在"工程"-"引用"中,选择
         “Microsoft ActiveX Data Objects Recordset 2.5 Library”
    用ADODC控件的连接代码如下:
    Dim str As String 
    str = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & app.path & "\data.mdb"
    Adodc1.ConnectionString = str
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "select * from table"
    Adodc1.Refresh
      

  4.   

    set adodc1.Connection="Provider=MSDASQL.1;Persist Security Info=False;Data Source=‘路径+你的数据库名’"
    set datagrid1.datasource=adodc1
      

  5.   

    set adodc1.Connection="Provider=MSDASQL.1;Persist Security Info=False;Data Source=‘路径+你的数据库名’"
    set datagrid1.datasource=adodc1