Click here to Skip to main content
14,327,564 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Experts,
I have to migrate more then 50,000 of records from 1 table to other depending on a particular where condition in the query.
For doing this I have used a Reader object and read from the source table and trying to insert the read data to my destination table.

The logic goes well till 35,000 records.But afterwards it gives me Object Reference Error .
Please Help. :((
Posted
Comments
Rob Grainger 3-Mar-11 13:54pm
   
Can you post the code you're using, or if not something representative?
Rate this:
Please Sign up or sign in to vote.

Solution 2

I think you do not want to use reader to copy some records from one table to other. You can use an SQL statement something like

insert into DestTable(Col1, Col2)
select Col1, Col2 from SourceTable where Col3 = 'some value'
   
Comments
Costica U 3-Mar-11 21:14pm
   
My 5.
I agree!
Rate this:
Please Sign up or sign in to vote.

Solution 1

Only explanation for this is memory leakage but generally it does not happens in manged code. you can use some memory analyzer tools available on the net to see what is causing the problem.

Other suggestion is read all the rows from tables first and store in some sort of object(to DataTable) and save it once.And if your database is SQLServer i would suggest you to use SQL Loader class it is much faster for doing bulk load(if you have some triggers on insert this will not work)
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

This is just me, but I'd never use an application to move data from one table to another if I have SQL Server, you can do what Sreejith says or you can try bulk copy the table, SQL has some features really easy to use for this
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100