Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I need to use for loop for inserting records in database at the same time i have another insert statement outside for loop, now how can I use sqltransaction there, or can i use scopetransaction there...
Thanks
Posted
Comments
OriginalGriff 17-Jun-12 1:44am    
Perhaps if you share the relevant code fragment, we could work out what you are trying to do a little more easily...
Use the "Improve question" widget to edit your question and provide better information.

1 solution

You need to use Transactions at code level based on your workflow you say.

Here:
MSDN: Local Transactions[^]
Using Transactions in ADO.NET[^]
 
Share this answer
 
Comments
barneyman 17-Jun-12 3:49am    
if you've got quite a few records in the loop to insert, you may want to pursue 'SQL Bulk insertions' - you can prep them before you execute it, and it will help to reduce the transaction lock exposure
Sandeep Mewara 17-Jun-12 4:08am    
Agreed. :thumbsup:

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900