service - New Transaction not allowed error in a web method that uses database transactions -


i writing wcf service method update 2 tables (header , details). need sure operation atomic, started transaction surrounding inserts.

however since web service method, other users call same function transaction being used.

one information, using custom orm kind of framework stores connection in session re-use.

when second web method call comes in, getting following exception:

system.data.sqlclient.sqlexception (0x80131904): new transaction not allowed because there other threads running in session.

i understand because transaction started first call not completed yet.

i want understand best practices using database transaction in web service , if can remedy situation without have create new connection every time.

well, sounds other method call trying use same connection first one, while not released properly.

you have connection pool , take connections from wcf request , return pool (by calling close() or dispose() or similar - depends on orm) after done database, before end of web service call:

-> wcf method -> start transaction -> connection pool -> work -> close connection (return pool) -> commit transaction -> return ->

using session store connection might not idea connection object cannot shared between threads.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -