我想把表中的2 个字段,例id,user  用select user from table where id="11",怎么去执行后,再返回recordset,然后在赋值。不知代码怎么写,谢谢!

解决方案 »

  1.   

    dim adoConnection As New ADODB.Connection
    dim adoRS As New ADODB.RecordsetWith adoConnection
        .ConnectionString = "DSN=MS Access 97 Database;DBQ=" & DATABASE  & ";DefaultDir=" & App.Path & ";DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;PWD='123'"
        .Open    
    End WithWith adoRS
        .ActiveConnection = adoConnection
        .Source = "select user from table where id='11'"
        .LockType = adLockReadOnly
        .Open
    End With
    sUser = adoRS!user
      

  2.   

    Dim conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim password As Stringconn.connectionstring = "
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\teacher.mdb;Persist Security Info=False"
    conn.Open
    sql = select user from table where id=1"
    rs.Open sql, conn, 3, 4
    if not rs.eof then 
    user = rs("user").Value
    else
    msgbox "密码错误"
    end if
    conn.Close