代码:
Private Sub Command1_Click()
    Dim adoPrimaryRs As Recordset
    Dim intN As Integer
    Dim adoDb As New Connection
    
    Set adoDb = New Connection
    adoDb.CursorLocation = adUseClient
    '数据库连接
    adoDb.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:\test.mdb;User ID=admin;Password=;"
    
    Set adoPrimaryRs = New Recordset
    intN = 0
    
    
    adoPrimaryRs.Open "select * from 条形码", adoDb, adOpenStatic, adLockOptimistic
    Set DataGrid1.DataSource = adoPrimaryRs
End Sub出错:
实时错误‘91’
对象变量或with块未设计

解决方案 »

  1.   

    补充:
    调试时指向位置:
    Set DataGrid1.DataSource = adoPrimaryRs
      

  2.   

    DataGrid1.DataSource = adoPrimaryRs
      

  3.   

    你看看工程引用中的microsft activex data objects2.1 library
      

  4.   

    Set adoPrimaryRs = New adodb.Recordset
      

  5.   

    '数据库连接
        adoDb.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:\test.mdb;User ID=admin;Password=;"
        adoDb.CursorLocation = adUseClient
    换位置
      

  6.   

    应该这样:
    Set adoDb = New adodb.Connection
    Set adoPrimaryRs = New adodb.Recordset