C# Threading and Sql Connections
Posted
by Jonathan M
on Stack Overflow
See other posts from Stack Overflow
or by Jonathan M
Published on 2010-04-07T14:18:59Z
Indexed on
2010/04/07
14:23 UTC
Read the original article
Hit count: 225
I have a method that attempts to update a sql server database in an ASP.NET application. If the update fails, it catches the exception and then queues the update in MSMQ, and then spins up a new thread that will later de-queue the pending update and try again. When the thread starts, it fails to open a database connection because it is attempting to connect using Network Service as the login. The sql connection is using Windows Authentication, and will work outside of the thread. If I put a breakpoint in the code that executes inside the new thread and check the Thread.CurrentPrincipal, it shows the Identity as being the correct user. Why is the sql connection attempting to be opened by the Network Service account?
I can elaborate further is necessary.
Thanks.
© Stack Overflow or respective owner