Solved

ODBC cannot read excel data?

Posted on 2000-02-29
4
293 Views
Last Modified: 2013-11-20
Hi,
  I'm having some problem in reading data from excel spreadsheets.
  I'm writing a Visual C++ (6.0) application and using the CRecordset class to read data from a excel data file. However, I can only read the field names but nothing else. (i.e. no data can be read from the file). Whenever I used any ODBC functions to access the data file, I always got the return value "SQL_ERROR". I tried to use same method to read from other type of database files (Access, dBase, CSV, txt) and all works without any problem. Can anyone tell me why and how to solve this problem?

First of all, I'd like to add the descriptions about  Microsoft Excel terms definitions at the end of the question so that you can understand the question well. I can use SQLExecDirect, SQLBindCol and SQLFetch to get data from other type of database files but not Excel file(.xls).

A series of worksheet rows that contain related data, such as an invoice database or a set of client names and phone numbers. A list can be used as a database, in which rows are records and columns are fields. The first row of the list has labels for the columns.

About using a list as a database

In Microsoft Excel, you can easily use a list as a database. When you perform database tasks, such as finding, sorting, or subtotaling data, Microsoft Excel automatically recognizes the list as a database and uses the following list elements to organize the data.

·      The columns in the list are the fields in the database.
·      The column labels in the list are the field names in the database.
·      Each row in the list is a record in the database.

0
Comment
Question by:chrishui
[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
4 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2571494
this info is not enough U have to elaborate what UR doing how U have organized UR spread sheet and how are U accessing them what U meant field in excel ?? Pl be more explainative...
0
 

Author Comment

by:chrishui
ID: 2574054
Edited text of question.
0
 

Author Comment

by:chrishui
ID: 2574071
Hi, I have add some comments to my question. I hope that will help you to understand by preblem.
Thanks alot.
0
 
LVL 4

Accepted Solution

by:
inpras earned 100 total points
ID: 2575204
Hi
U have to format UR excel sheet before reading data from it U have to set a range by going ti INsert menu and choosing Name.
did U set the range for UR data in the excel sheet?
if not set it ODBC requires that a range should be set I think that is the problem UR facing.
U have demo project for reading data from excel here U will come to know what mistake UR doing here

http://www.codeguru.com/mfc_database/18-15-1.shtml
Hope this helps
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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 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