473,796 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=Micr osoft.Jet.OLEDB .4.0; " +
"data source='" + SaveLocation + " '; " + "Extended Properties='Exc el
8.0;IMEX=1;'")
Dim da As New OleDbDataAdapte r("select * from
[Sheet1$]", cnn)
da.TableMapping s.Add("Table", "TableCom")
Dim ds As New DataSet
da.Fill(ds)

Please help me in this

Aug 4 '06 #1
2 6360
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=Micr osoft.Jet.OLEDB .4.0; " +
¤ "data source='" + SaveLocation + " '; " + "Extended Properties='Exc el
¤ 8.0;IMEX=1;'")
¤ Dim da As New OleDbDataAdapte r("select * from
¤ [Sheet1$]", cnn)
¤ da.TableMapping s.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_MACH INE\SOFTWARE\Mi crosoft\Jet\4.0 \Engines\Excel

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

"Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & SaveLocation & ";Extended Properties=""Ex cel 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=Micr osoft.Jet.OLEDB .4.0; " +
¤ "data source='" + SaveLocation + " '; " + "Extended Properties='Exc el
¤ 8.0;IMEX=1;'")
¤ Dim da As New OleDbDataAdapte r("select * from
¤ [Sheet1$]", cnn)
¤ da.TableMapping s.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_MACH INE\SOFTWARE\Mi crosoft\Jet\4.0 \Engines\Excel

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

"Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & SaveLocation & ";Extended Properties=""Ex cel 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
8013
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
8900
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 this out of an XML file or Excel Template file. Next I need to convert a dataset to xml and try and transform this data into the users xml file..........i've seen a few things on this but havent had much success...
7
11785
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 where usrname = " + "'" + userText.Text + "'"; oda = new OleDbDataAdapter(groupSelect, groupConnect); DataSet ds = new DataSet(); oda.Fill(ds, "group");
1
1921
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 USENET...get rewarded for it!
1
2067
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 (truncated of course, you get the idea): <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns1:TransactionDetails xmlns:ns1="urn:Microsoft.IT.LicensePosition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ns1:Trans> ...
2
23027
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 app from the Excel file? I have made a reference to the Excel 11.0 object library, but am not sure what code comes next. Thanks,
2
331
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
3124
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, dataset.writexml works great (got the code from http://forums.devx.com/archive/index.php/t-57273.html ) The only question I have is, when Excel opens up, it isn't the view I would prefer. It opens as a read-only workbook, I would prefer as an
3
2272
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; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; using System.Net.Security;
1
6694
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 extracting all tables and it's data from any given database! I was searching the net for a program like this, but I didn't come accross any (free) versions. So I decided to write it myself. To get this code to work, you need to add a reference to...
0
9535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10467
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4130
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 we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.