• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

sql statement of MS Excel


hi!again....

i need to know code to access MS Excel and write  a sql statement to select some data.

any library that need?

can i use the the ADO to do this?just like i do on MS Access.

select field
from table
where ....

what to replace the field,table....

 
0
iven
Asked:
iven
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
With ADO you can use, just connect to the file using the ODBC driver you have certainly installed for excel.
Use the DBQ=path\filename.xls in the connection string, and in the select would be
SELECT * FROM <sheetname>
or eventually
SELECT * FROM <sheetname>$

CHeers
0
 
kavithagCommented:
You need to use the ADO diver for query and Microsoft Excel 9.0 library to display the selected data into Excel.
0
 
ivenAuthor Commented:
angellll

hi!
can u show me some example?
thanx!
0
 
ivenAuthor Commented:
angellll,

i use DAO to do this:

filepath = "d:\testing.xls"
Set db = OpenDatabase(filepath, False, False, "Excel 8.0;HDR=yes;")
Set rs = db.OpenRecordset("select * from sheet1")

what is the problem of this?when i run this sql,the error
"...could not find the object "sheet1"...."
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
as I mentionned above, try sheet$

CHeers
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now