Solved

ODBC cannot read excel data?

Posted on 2000-02-29
4
277 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 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

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

14 Experts available now in Live!

Get 1:1 Help Now