471,317 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

Reading CSV File into SQL never completes

(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
Feb 3 '06 #1
2 6330
"Antonio Tirado" <An***********@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
(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.
--
Feb 4 '06 #2
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.

"Nick Malik [Microsoft]" wrote:
"Antonio Tirado" <An***********@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
(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.
--

Feb 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Greg Lindstrom | last post: by
21 posts views Thread by JoKur | last post: by
2 posts views Thread by mboyda | last post: by
4 posts views Thread by Patrick Altman | last post: by
13 posts views Thread by cmdolcet69 | last post: by
10 posts views Thread by puzzlecracker | last post: by
reply views Thread by rosydwin | last post: by

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.