ODBC cannot read excel data?
Posted on 2000-02-29
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.