Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Error while updating data through dataset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AVL - 28 Jan 2008 12:58 GMT
Hi,
I've a  requirement where in I need to read the data from a csv file and
load the data into the sql database. The file has around 1 lakh records. I'm
reading 300 records at a time from the file, loading into a dataset.
From the dataset, I'm reading the rows sequentially,and updating one by one
in to the database. This happens with a sql trnasaction.

The problem is here with the performance.. The file to be loaded exists on
one server and the database exists on another server. The loading process is
too slow
and it breaks with the below error
'The SqlTransaction is closed;it is no longer usable'.
I've searched on the google..but couldn't get appropriate resolution. Can
someone help me out?
Alvin Bruney [ASP.NET MVP] - 28 Jan 2008 15:36 GMT
Why don't u just load the files into the database using a sql script rather
than thru the application? It's a lot more efficient.

Signature

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------

> Hi,
> I've a  requirement where in I need to read the data from a csv file and
[quoted text clipped - 13 lines]
> I've searched on the google..but couldn't get appropriate resolution. Can
> someone help me out?
sloan - 28 Jan 2008 20:19 GMT
To help performance, you have two options.

1.  Push the entire XML into sql server.  Large overhead, and maybe not what
you want.

2.  (My suggestion).  Instead of pushing the records one by one into the db,
make the number configurable.
For example, lets make it 1000.

Use the IDataReader to loop over the CSV file.
Put 1000 records into the DataSet.
Write a usp (user stored procedure) which accepts @xml_doc text. (which will
be xml).
Do a bulk insert/update using the xml.

You will save alot of time doing this.

There are other options, but based on what you put in your OP, I'd go for
#2.

how do you do a dataset bulk insert/update, you ask?

Go here:
http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/268be0
e152d8b876

read the MS links I provide.

The key is to use the ds.GetXml ....to get 1000 records worth records.
Then push those 1000 records into TSQL as xml.
Parse the xml into a @variable or #temp table.
Do your updates/inserts from there.

my uspProductUpdate is a fine tuned version......

Because index rebuilding happens after the 1000 records get
updated/inserted, you save time that way as well.

..

Then experiment with the 1000 number.  Maybe 5000, maybe 500 is your sweet
spot number.

..

> Hi,
> I've a  requirement where in I need to read the data from a csv file and
[quoted text clipped - 13 lines]
> I've searched on the google..but couldn't get appropriate resolution. Can
> someone help me out?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.