473,511 Members | 15,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

read excelfile with ADO

Hello,

I'm using ADO to read an excelfile in a datagrid as follows:

Dim cnn As NewOleDb.OleDbConnection("Provider=Microsoft.Jet.O LEDB.4.0;
Data Source=" & filename & ";Extended Properties=""Excel
8.0;HDR=YES;""")
Dim da As New OleDb.OleDbDataAdapter("Select * from [Sheet1$]", cnn)
Dim dt As New DataTable("excel")
da.Fill(dt)
Datagrid1.datasource = dt
This works fine. But when a certain column on the second row (the first
row are the headers) contains an integer, then ADO assumes that this
whole column contains integers (except for the header offcourse). And
for each value that is not an integer, ADO replaces the string with the
DBNull value.

What am I doing wrong? Or is this a known bug? Are there any workarounds?

Thanks for the help,

Steven
Mar 24 '06 #1
2 1088
Steven,

Here is a url that explains your options:

http://www.sqldts.com/default.aspx?254

Kerry Moorman
"steven" wrote:
Hello,

I'm using ADO to read an excelfile in a datagrid as follows:

Dim cnn As NewOleDb.OleDbConnection("Provider=Microsoft.Jet.O LEDB.4.0;
Data Source=" & filename & ";Extended Properties=""Excel
8.0;HDR=YES;""")
Dim da As New OleDb.OleDbDataAdapter("Select * from [Sheet1$]", cnn)
Dim dt As New DataTable("excel")
da.Fill(dt)
Datagrid1.datasource = dt
This works fine. But when a certain column on the second row (the first
row are the headers) contains an integer, then ADO assumes that this
whole column contains integers (except for the header offcourse). And
for each value that is not an integer, ADO replaces the string with the
DBNull value.

What am I doing wrong? Or is this a known bug? Are there any workarounds?

Thanks for the help,

Steven

Mar 24 '06 #2
Thank you very much !! Just adding "IMEX=1" to my connectionstring did
the job!!

Steven

Kerry Moorman schreef:
Steven,

Here is a url that explains your options:

http://www.sqldts.com/default.aspx?254

Kerry Moorman

Mar 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
11631
by: Steven T. Hatton | last post by:
I know of a least one person who believes std::ifstream::read() and std::ofstream::write() are "mistakes". They seem to do the job I want done. What's wrong with them. This is the code I...
1
3979
by: Jose Reckoner | last post by:
I'm running python 2.3 on Windows XP. Anyone have a quick small script to convert .DT1 and .DEM data to ASCII or some other format? I don't need a viewer. Thanks!
5
43405
by: barbara_dave | last post by:
Hi All, I need to read data from a Excel spreadsheet, but I got the problem when I tried the code below: StringBuilder sbConn = new StringBuilder();...
0
1610
by: minhtran | last post by:
Hi Everyone Lately, I found the code as to read all file from Excel file as ".xls" from Excel before 2007, but does not work for ".xlsx" Excel 2007, Please, any help for me (new hired database...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.