Reading CSV File into SQL never completes

G

Guest

(ASP.NET c# Question)

Hi, I have this odd problem:

I receive a CSV File through file upload. Using an OleDB.Datareader i read
each row of the file and insert it into SQL.

The problem is that for some reason when the file goes over 15k the program
gets stuck. All rows are read and inserted correctly into SQL. The program is
not generating duplicate entries. It is just there waiting for something
until the session expires.

I tried generating a Dataset and reading from there into SQL but the result
is the same. Ialso tried saving the file into xml and reading from a dataset
of this XML file but the result is the same.

Thanks in advance
 
N

Nick Malik [Microsoft]

Antonio Tirado said:
(ASP.NET c# Question)

Hi, I have this odd problem:

I receive a CSV File through file upload. Using an OleDB.Datareader i read
each row of the file and insert it into SQL.

The problem is that for some reason when the file goes over 15k the
program
gets stuck. All rows are read and inserted correctly into SQL. The program
is
not generating duplicate entries. It is just there waiting for something
until the session expires.

I tried generating a Dataset and reading from there into SQL but the
result
is the same. Ialso tried saving the file into xml and reading from a
dataset
of this XML file but the result is the same.

Thanks in advance

I'm always amazed when someone uses an OleDB data reader to read a CSV file.
Why on earth would you do that? You don't get the control over error
handling that you would get if you simply read the data in a stream and
parsed it yourself. CSV is SO simple that it just doesn't make sense to use
an adapter, especially one that conforms to a database interface, to
interpret it for you.

The culprit is probably your data. If you have a double-quote in the data,
then your adapter is looking for a close quote. On the other hand, perhaps
you have no CRLF at the endof the last line, where the adapter is expecting
a CRLF at the end of the last line. Look at the data... it's probably the
culprit.


--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
G

Guest

I'm using the OleDB reader because I save on coding to parse each row. The
OleDB component returns an object[] for which I only have to cast to obtain
and use a variable in its format and not a standard string. You might lose
some control but I think you gain in functionality.

The use of double-quotes is standard in CSV files and the OleDB component
interprets them perfectly.Though I think it is looking for the <EOF>
character.
 

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

Top