用ado最好加上new adodb.recordset

解决方案 »

  1.   

    dim db as adodb.connection
    dim ado1 as adodb.recordset
    dim adoPrimaryRS as adodb.recordset
    dim adoenter as adodb.recordsetSet db = New Connection
      db.CursorLocation = adUseClient
      db.Open "PROVIDER=MSDASQL;driver={SQL Server};server=" + servername + ";uid=" + entername + ";pwd=" + enterpass + ";database=" + databasename + ";"
    Set adoPrimaryRS = New Recordset
      Set adoenter = New Recordset
      adoPrimaryRS.Open "select 学号,密码 from " + tablename + "", db, adOpenStatic, adLockOptimistic
      
      adoenter.Open "select 学号,密码 from " + tablename + "", db, adOpenStatic, adLockOptimistic
      
      
      Set ado1= adoPrimaryRS
    要到别的机上运行必需打包,并将用到的dll与ocx打进去。
      

  2.   

    上面的有点错
    dim db as adodb.connection
    dim ado1 as adodb.recordset
    dim adoPrimaryRS as adodb.recordset
    dim adoenter as adodb.recordsetSet db = New adodb.Connection
      db.CursorLocation = adUseClient
      db.Open "PROVIDER=MSDASQL;driver={SQL Server};server=" + servername + ";uid=" + entername + ";pwd=" + enterpass + ";database=" + databasename + ";"
    Set adoPrimaryRS = New adodb.Recordset
      Set adoenter = New adodb.Recordset
      adoPrimaryRS.Open "select 学号,密码 from " + tablename + "", db, adOpenStatic, adLockOptimistic
      
      adoenter.Open "select 学号,密码 from " + tablename + "", db, adOpenStatic, adLockOptimistic
      
      
      Set ado1= adoPrimaryRS