how to create a table in excel?

B

Britt

Hi,

I use this connection string to connect to excel:

ConnectionString="Provider = Microsoft.Jet.OLEDB.4.0; Data Source =
c:\\excel\mydb.xls; Extended Properties=Excel 8.0;"

Doing this, it accesses the table in sheet1: sql = "select field1 from
data;", but how to access a table located in the same (mydb.xls) file but
in sheet2?
Thanks
Britt
 
P

Paul Clement

¤ Hi,
¤
¤ I use this connection string to connect to excel:
¤
¤ ConnectionString="Provider = Microsoft.Jet.OLEDB.4.0; Data Source =
¤ c:\\excel\mydb.xls; Extended Properties=Excel 8.0;"
¤
¤ Doing this, it accesses the table in sheet1: sql = "select field1 from
¤ data;", but how to access a table located in the same (mydb.xls) file but
¤ in sheet2?

In Excel the Worksheet name is the table name. You simply specify it in your SELECT statement:

SELECT * FROM SHEET2$


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top