?
Solved

ODBC cannot read excel data?

Posted on 2000-02-29
4
Medium Priority
?
325 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
  • 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 300 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

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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Screencast - Getting to Know the Pipeline
Suggested Courses

749 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