You might have to Open the Excel Workbook Object first and retrieve a list
of the sheet names then construct and run your SQL
Doug
[quoted text, click to view] "Solel Software" <Solel Software@discussions.microsoft.com> wrote in message
news:E75E6161-D6A6-4792-9405-F0467FBB333B@microsoft.com...
> Hello,
>
> I am looking to open an Excel spreadsheet in ADO.NET using OLEDB's Jet
engine. I have a conn string as follows:
>
> Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.xls;Extended
Properties=Excel 8.0;
>
> I am attempting to put together the SQL to query this spreadsheet. The
examples I have found all look like:
>
> Select * From [Sheet1$]
>
> but this explicitly names the worksheet in the spreadsheet. Is there a
way to indicate the worksheet by index instead of name? I am attempting to
build an automatic parser for an excel spreadsheet and am looking to query
the first worksheet but its name could vary from spreadsheet to spreadsheet.
How should I do this? If it is not possible to reference the worksheet
within the spreadsheet by index in the SQL Select statement, then is there a
way to discover the name of the worksheet at run time without starting an
instance of Excel? Thanks for your help!