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

import CSV file directly into a dataset

is that doable?

I have built a CSV string using a stringbuilder.

I now want to take this data and populate a DS.

How do I do that?

I've gotten this far:

dim ds as new dataset
Dim objOleDbAdapter As System.Data.OleDb.OleDbDataAdapter
Dim objConnect2 As New System.Data.OleDb.OleDbConnection("[THIS IS WHERE I'M
STUCK]'")
objOleDbAdapter.Fill(ds)

As you can see, I'm stumped on the actual connection string. I have examples
connecting to a physical file, but not a string.

-Darrel
Mar 8 '06 #1
6 1572
You probably need to loop through each line of your CSV and create a
DataRow from the data. Then add the DataRow to your DataTable.

Mar 8 '06 #2
On Wed, 08 Mar 2006 11:44:33 -0600, darrel wrote:
is that doable?

I have built a CSV string using a stringbuilder.

I now want to take this data and populate a DS.

How do I do that?

I've gotten this far:

dim ds as new dataset
Dim objOleDbAdapter As System.Data.OleDb.OleDbDataAdapter
Dim objConnect2 As New System.Data.OleDb.OleDbConnection("[THIS IS WHERE I'M
STUCK]'")
objOleDbAdapter.Fill(ds)

As you can see, I'm stumped on the actual connection string. I have examples
connecting to a physical file, but not a string.

-Darrel

Another way, write an XML schema to represent the CSV. Then load the XML
into the dataset.
Mar 8 '06 #3
You probably need to loop through each line of your CSV and create a
DataRow from the data. Then add the DataRow to your DataTable.


Well, in hindsight, that probably makes a lot more sense. Just go from DS to
new DS.

I'll give that a shot!

-Darrel
Mar 8 '06 #4
Here is another option, with Xml.

Also check this post I made a while back:
http://groups.google.com/group/micro...214c3bcca94224
(or search
http://groups.google.com/?hl=en for "xml to xml transformation" and
"spaces.msn.com"
)







"darrel" <no*****@nowhere.com> wrote in message
news:e1*************@TK2MSFTNGP15.phx.gbl...
is that doable?

I have built a CSV string using a stringbuilder.

I now want to take this data and populate a DS.

How do I do that?

I've gotten this far:

dim ds as new dataset
Dim objOleDbAdapter As System.Data.OleDb.OleDbDataAdapter
Dim objConnect2 As New System.Data.OleDb.OleDbConnection("[THIS IS WHERE I'M STUCK]'")
objOleDbAdapter.Fill(ds)

As you can see, I'm stumped on the actual connection string. I have examples connecting to a physical file, but not a string.

-Darrel

Mar 8 '06 #5
If you look around there are several implementations of "CSVDataReaders"
around.
With a file, its easy - just use a JET OleDb connection string to the folder
with the Text file provider nomenclature, and do "select * from mystuff.csv"
and it goes right into an OleDbDataReader.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"darrel" wrote:
is that doable?

I have built a CSV string using a stringbuilder.

I now want to take this data and populate a DS.

How do I do that?

I've gotten this far:

dim ds as new dataset
Dim objOleDbAdapter As System.Data.OleDb.OleDbDataAdapter
Dim objConnect2 As New System.Data.OleDb.OleDbConnection("[THIS IS WHERE I'M
STUCK]'")
objOleDbAdapter.Fill(ds)

As you can see, I'm stumped on the actual connection string. I have examples
connecting to a physical file, but not a string.

-Darrel

Mar 8 '06 #6
With a file, its easy


Right. But I don't have a file...just a string.

I suppose I could write the string to a file then reimport. In the end,
though, I tought it probably makes more sense just to go from DS to DS
instead of CSV in the middle.

-Darrel
Mar 8 '06 #7

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

Similar topics

2
by: Eric Caron | last post by:
Hi I try to import file in a dataset. How I can do this ?
1
by: Ed Bacon | last post by:
I am trying to produce a generic "audit report" for various transactions in our application. Each transaction type defines a document (and has an associated schema). When a transaction leads to a...
3
by: Anthony Robinson | last post by:
I have an issue I've been working on that has proven to be quite troublesome. I already have an idea of what the anwser may be, but would like to solicit some suggestions or other ideas from you...
3
by: Schultz | last post by:
I would like to know if it is possible to import data from MS Excel 2000 to a dataset using asp.net. The excel file would need to be uploaded to the server from a web page first, before the loaded...
4
by: BostonNole | last post by:
I am looking for suggestions on the most efficient way to import 7 different fixed width files into a DataSet. Not all at the same time. One file at a time, but the format could change from file...
10
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in...
1
by: The_Fakir_42 | last post by:
Hi, I have a very tricky problem... I import an XLS file from my asp web application; this xls file contains lots of single-cell named areas. Usually, I know how to get them, this way : '...
7
by: Ron Adam | last post by:
from __future__ import absolute_import Is there a way to check if this is working? I get the same results with or without it. Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win 32 ...
4
by: Max2006 | last post by:
Hi, We are developing a SQL server based asp.net application. As part of requirement we should allow users import/export some relational data through web user interface. We are investigation...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.