Re: Load a string of CSV from memory into a dataset
- From: "Sahil Malik [MVP]" <contactmethrumyblog@xxxxxxxxxx>
- Date: Wed, 25 May 2005 18:12:58 -0400
Yes there is. As a matter of fact, you should avoid writing to the disk as
that is hella slow.
What you can do however is that the "Stream" you get - (is it
MemoryStream?) - which after decryption and just before writing to the CSV
file - subject that to a "StreamReader" - to get a string out of it.
Great, now that you have a CSV'ed string out of it, split the string for New
lines.
Then run a foreach on the resulting array and split each line (array
element) using the "," character.
For each sub array element - create an object array - and do a
DataTable.LoadDataRow(passinthearray,true).
Thats it. Problem solved.
- Sahil Malik [MVP]
http://codebetter.com/blogs/sahil.malik/
"andrei" <andrei.toma@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:#PDYoXWYFHA.3356@xxxxxxxxxxxxxxxxxxxxxxx
> Hi Group,
>
> Here is what I'm trying to do in my application:
> 1. the customer uploads an encrypted file to the server (it's a ASP.NET
> application)
> 2. the uploaded file is decrypted to a comma separated list of values
> 3. the list is being written to a CSV file
> 4. the csv file is being loaded into a datatable, using OleDbDataAdapter
> 5. the recordset, after some checking and validation, is being written to
a
> SQL database.
>
> Question:
>
> Is it possible to skip somehow the steps where I'm writing the comma
> separated list to a csv file and then reloading the list into a datatable?
> Something like loading the datatable directly from the comma separated
> string **in memory** ?
>
> Many thanks !
>
> Andrei.
>
>
.
- Follow-Ups:
- Re: Load a string of CSV from memory into a dataset
- From: andrei
- Re: Load a string of CSV from memory into a dataset
- References:
- Load a string of CSV from memory into a dataset
- From: andrei
- Load a string of CSV from memory into a dataset
- Prev by Date: Re: How does Dataset.Relations work internally?
- Next by Date: Re: Invalid Key node inside constraint error
- Previous by thread: Load a string of CSV from memory into a dataset
- Next by thread: Re: Load a string of CSV from memory into a dataset
- Index(es):
Relevant Pages
|