strSQL = "select name from accts where acct='100001'" 
strConnect  = "Provider=MSDAORA;" _ 
        & "Data Source=mydatabase;" _ 
        & "User ID=myuserid;" _ 
        & "Password=mypassword;" 
Set adoConnection = CreateObject("ADODB.Connection") 
adoConnection.Open strConnect 
results = adoConnection.execute(strSQL) 
'在此取出第一列数据,应该怎样写代码?
adoConnection.Close 

解决方案 »

  1.   

    dim a as string
    ……with results
        .CursorType = adOpenStatic
        .LockType = adLockReadOnly    
        set results = adoConnection.execute(strSQL)
        if not results.eof then
            a =.fields(0).value
        endif
    end with
      

  2.   

    strSQL = "select name from accts where acct='100001'" 
    strConnect  = "Provider=MSDAORA;" _ 
        & "Data Source=mydatabase;" _ 
        & "User ID=myuserid;" _ 
        & "Password=mypassword;" 
    Set adoConnection = CreateObject("ADODB.Connection") 
    Set rs = CreateObject("ADODB.Recordset") 
    rs.open strsql,adoConnection debug.print rs.fields(0).value
    详细的你可以参考一下ADO的手册。
     
      

  3.   

    LS 的2位:
    我调试了一下,有错误:Object doesn't support this property or methord:'rs.eof'  'rs.fields'