Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenDataSource/OpenRowSet Excel - what's the workbook called?!

Status
Not open for further replies.

ChainsawJoe

Programmer
Dec 5, 2000
154
GB
I'm trying to use OpenRowSet or OpenDataSource to query an Excel file, as demonstrated here:
But when using the code
Code:
SELECT * 
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
  'Data Source="C:\test\Book1.xls";
    User ID=;Password=;Extended properties=Excel 8.0')...Book1$

With OpenRowSet I get the error:
Code:
Could not process object 'Select * from [Book1$]'. The OLE DB provider 'Microsoft.Jet.OLEDB.4.0' indicates that the object has no columns.

And with OpenDataSource:
Code:
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' does not contain table 'ThisWorkbook$'.  The table either does not exist or the current user does not have permissions on that table.

(and it's not a user auth issue, as when I type in gibberish as the userID I get the error
Code:
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. Authentication failed.
instead)

It's s test excel file that contains one column with values 100, 200, 300, 400. I even edited the code for the current sheet so I coulde rename the workbook to "Book1", but to now avail.

And yes, I know almost NOTHING about excel. (I only ever used it to demonstrate easter eggs - y'know the old flight sim thing.. heheh.. great fun..)

Any tips/help/pointers would be greatly appreciated!

TIA

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Ah. My bad. Sorry! It's meant to be the *Sheet* name, not the workbook name... I changed it to
Code:
SELECT * 
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
  'Data Source="C:\test\Book1.xls";
    User ID=;Password=;Extended properties=Excel 8.0')...[Sheet1$]
and it's all good.

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top