473,414 Members | 1,862 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,414 software developers and data experts.

convert Excel to dataset

Hi
when i convert Excel file to dataset using the following code, i find
that, some col. such as

Col1
------
404
403
NOT
222
is converted as

col1
-----
404
403
<null>
222

..I use this code to convert
Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
"data source='" + SaveLocation + " '; " + "Extended Properties='Excel
8.0;IMEX=1;'")
Dim da As New OleDbDataAdapter("select * from
[Sheet1$]", cnn)
da.TableMappings.Add("Table", "TableCom")
Dim ds As New DataSet
da.Fill(ds)

Please help me in this

Aug 4 '06 #1
2 6301
On 4 Aug 2006 06:06:40 -0700, "karups" <al***********@gmail.comwrote:

¤ Hi
¤ when i convert Excel file to dataset using the following code, i find
¤ that, some col. such as
¤
¤ Col1
¤ ------
¤ 404
¤ 403
¤ NOT
¤ 222
¤
¤
¤ is converted as
¤
¤ col1
¤ -----
¤ 404
¤ 403
¤ <null>
¤ 222
¤
¤ .I use this code to convert
¤ Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
¤ "data source='" + SaveLocation + " '; " + "Extended Properties='Excel
¤ 8.0;IMEX=1;'")
¤ Dim da As New OleDbDataAdapter("select * from
¤ [Sheet1$]", cnn)
¤ da.TableMappings.Add("Table", "TableCom")
¤ Dim ds As New DataSet
¤ da.Fill(ds)
¤

The IMEX argument should have taken care of the mixed mode column issue.

You could also try changing the TypeGuessRows setting in the registry to 0. It is found at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engi nes\Excel

I'm assuming your connection string is being evaluated properly but you may want to try double
quotes instead of single quotes:

"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SaveLocation & ";Extended Properties=""Excel 8.0;IMEX=1"""
Paul
~~~~
Microsoft MVP (Visual Basic)
Aug 4 '06 #2

Paul Clement wrote:
On 4 Aug 2006 06:06:40 -0700, "karups" <al***********@gmail.comwrote:

¤ Hi
¤ when i convert Excel file to dataset using the following code, i find
¤ that, some col. such as
¤
¤ Col1
¤ ------
¤ 404
¤ 403
¤ NOT
¤ 222
¤
¤
¤ is converted as
¤
¤ col1
¤ -----
¤ 404
¤ 403
¤ <null>
¤ 222
¤
¤ .I use this code to convert
¤ Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
¤ "data source='" + SaveLocation + " '; " + "Extended Properties='Excel
¤ 8.0;IMEX=1;'")
¤ Dim da As New OleDbDataAdapter("select * from
¤ [Sheet1$]", cnn)
¤ da.TableMappings.Add("Table", "TableCom")
¤ Dim ds As New DataSet
¤ da.Fill(ds)
¤

The IMEX argument should have taken care of the mixed mode column issue.

You could also try changing the TypeGuessRows setting in the registry to 0. It is found at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engi nes\Excel

I'm assuming your connection string is being evaluated properly but you may want to try double
quotes instead of single quotes:

"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SaveLocation & ";Extended Properties=""Excel 8.0;IMEX=1"""
Paul
~~~~
Microsoft MVP (Visual Basic)


ya that worked for me now
Thats great
I changed in the registry and its fetching the records correctly..
Thank u paul

Aug 8 '06 #3

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

Similar topics

3
by: Chris | last post by:
Could someone please provide me an effective means of exporting data from a data set (or data grid) to Excel?
9
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save...
7
by: kscdavefl | last post by:
I am running the following code to retrieve a DataSet: public DataView CreateGroupSource() { string groupConnect = Session.ToString(); string groupSelect = "Select grpname from Maxusergroups...
1
by: TaeHo Yoo | last post by:
How to convert a dataset to excel spreadsheet in windows based application?? Thanks a lot in advance. *** Sent via Devdex http://www.devdex.com *** Don't just participate in...
1
by: SL | last post by:
Hi - I'm fairly new to manipulating xml and I have an excel workbook and on one of the sheets is apparently a listobject... using it's xmlmap.export function I get an xml file that looks like this...
2
by: Ronald S. Cook | last post by:
Hi, I need to open an Excel file from within my ASP.NET app and read data. I'm guessing the most like format in ASP.NET would be a DataTable. Regardles,, how do I get the data into my ASP.NET...
2
by: karups | last post by:
Hi when i convert Excel file to dataset using the following code, i find that, some col. such as Col1 ------ 404 403 NOT 222
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
3
by: binny | last post by:
i use jet engine ,and oledb database but with this i get four errors which r compile time errores,plz help me to solve these errors i wrote this programe bt it is not working . using System.Web;...
1
by: DennisBetten | last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel. What does this code do: As the title says, this code is capable of...
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
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...
0
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
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.