473,383 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Help for reading data from Excel file

hi,

I am trying to read data from an excel file. in one column data is like this:
1
1.1
1.1.1
1.1.2
1.2
1.2.1
1.2.2
and so on.

I use OleDbConnection to get data. my code is like this:
(1)
while (reader.Read())
{
string temp= reader[1].ToString();
}
as a result, it missed data: 1, 1.1, 1.2. (looks like these data are treated as double, not string)

(2)
when I use
temp = reader.GetString(1); // it gave me InvalidCastException

Then I tried to use datatable and it also gave me same problem.
So, how to read all those data and save them into string array?
I really appreciate if anyone can help me.

Thank you very much
Aug 2 '09 #1
3 2843
Never mind my question. it is solved already. Thanks anyway
Aug 3 '09 #2
Hi, I'm trying to read data from Excel in VC++. Can you post your solution. Thanks in advance.
Sep 30 '09 #3
Hi, LalithaSJ,

if you have the same problem, just add something after connection string:
Example:
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +
your excel file location+
";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"");

Here,
HDR=Yes: First row of excel file will be treated as column name.
HDR=No: No column name. first row will be treated as data.
IMEX=1: All data in excel file will be treated as String.
IMEX=0: Datatype of each column will be collected based on excel file
column datatype setting

BTW, I am using C#. But I believe it will be pretty similar to C++. Hope it could give an idea to solve data reading problem.

Cheer.
Harbin2010
Oct 1 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Flack | last post by:
Hello, When the user of my app selects some rows from an open excel file and drag-n-drops them onto my form, I need to be able to parse those lines and create a datatable that would match the...
7
by: Niyazi | last post by:
Hi, I am developing small insurance application using VB.NET and SQL server 2000. My tables in SQL server are: tbl_Customer (stores the custmer information) tbl_CustImage ...
3
by: Bharathi Kumar | last post by:
Hi, In my windows application, I have created excel.application object and read the excel data. I saved the data to sql server also. The problem Iam facing is when I create an instance of...
17
by: OdAwG | last post by:
Just some questions regarding tables. I am new Access Database and need a little help. I have the following data listed below 01. I have a table called tbl_Customer with the following...
3
by: Brad | last post by:
I'm having a problem reading data from an Excel file into a dataset. Can anybody give me an idea of what's happening? I've included the problematic source and the error message to the end of this...
0
by: ramyanet | last post by:
Dear All, I have retrieved the data from excel to dataset and i have updated the database. Now if i upload the excel file for the second time with different data and execute,its returning...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
2
by: Bill | last post by:
I have a 200 record database that includes a date/time field, AnnivDate, for a wedding anniversary. AnnivDate has nulls and some incorrect year data. I have been creating the Access database...
3
by: Don | last post by:
I'm using Access 2000. My database collects lots and lots of data. One aspect of that is to collect dimensional data from multiple checks during the day. The way I've done that is to have a...
3
by: thedouble13man | last post by:
I am relatively proficient with VBA and primarily use it for Excel. I am trying to do something that seems as though it should be easy but I have been struggling and cannot seem to figure it out...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.