Solved

sql statement of MS Excel

Posted on 2002-04-15
5
199 Views
Last Modified: 2012-05-04

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
Comment
Question by:iven
  • 2
  • 2
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 15 total points
ID: 6941475
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
 
LVL 1

Expert Comment

by:kavithag
ID: 6941694
You need to use the ADO diver for query and Microsoft Excel 9.0 library to display the selected data into Excel.
0
 

Author Comment

by:iven
ID: 6944124
angellll

hi!
can u show me some example?
thanx!
0
 

Author Comment

by:iven
ID: 6944194
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6944200
as I mentionned above, try sheet$

CHeers
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now