import CSV file directly into a dataset

D

darrel

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
 
J

Jacob

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.
 
I

intrader

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.
 
D

darrel

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
 
G

Guest

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
 
D

darrel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top