Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sql statement of MS Excel

Posted on 2002-04-15
5
Medium Priority
?
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 45 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 143

Expert Comment

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

CHeers
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

688 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