I am placing approximently 3 million records inside a database using this solution. Eventually once the application continues to be placing records for some time (my last run survived around 4 hrs), it provides a timeout using the following SqlException:
"SqlExcepetion: Timeout expired. The timeoutperiod passed just before completing the operation or even the server isn't reacting."
What's the easiest method to handle this exception? It is possible to method to stop this from happening or must i catch the exception?
Thanks ahead of time!
If all you have is really a hammer, every problem appears like a nail.
Seriously, even Attempting to use Linq2SQL for placing 3 million records is really a damaged approach. ORM's are lots of good stuff, they aren't bulk place elements.
I would recommend:
- Create the table data right into a file
- Load the file using appropriate tools (bulk load mechanism). You wil lbe impressed by the performance (hint: I load about 600 million records in fifteen minutes))
Bulk load provides extensive performance advantages. Naturally presuming you talk of something similar to an ETL load process here - however i miss out on a 3 million load as anything except an information warehouse / confirming / archiving type of load operation, it definitlely and per definition isn't real-time transaction processing )
Make use of the right tool to do the job.
Produce a SQL script (or string), and execute that directly.
L2SQL isn't designed for mass procedures such as this.
I believe you've to improve the CommandTimeout of the command.
Solution are available here