Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

Error 80040e21... rs.Open "SELECT ...

Dim cn As ADODB.Connection
dim rs As ADODB.Recordset

Set cn = New ADODB.Connection
    cn.Open "DRIVER={Microsoft Excel Driver (*.xls)};DriverId=790;ReadOnly=True;" & "DBQ=" & "c:\book1.xls" & ";"
Set rs = New ADODB.Recordset

'****   Following line errors:  ODBC driver does not support the requested properties*****

    rs.Open "SELECT * FROM [SHEET1]", cn, adOpenForwardOnly, adLockReadOnly, adCmdText
    While Not rs.EOF
        MsgBox rs(0)
    rs.MoveNext
    Wend
    rs.Close
Set rs = Nothing
    cn.Close
Set cn = Nothing

Why am I getting this error?
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

ASKER

Well, $ was missing from worksheet name.  I didn't think it is mandatory to have it there.

Mike
ASKER CERTIFIED SOLUTION
Avatar of aelatik
aelatik
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
rs.Open "SELECT * FROM [SHEET1]", cn, 3, 2

TRy this instead
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial