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
Solved

sql statement of MS Excel

Posted on 2002-04-15
5
202 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 143

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 143

Expert Comment

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

CHeers
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

791 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