简体   繁体   中英

Use same db connection across multiple activities wrapped in a TransactionScope in Windows Workflow Foundation?

In Windows Workflow Foundation I want to wrap multiple code activities inside a TransactionScope activity. The code activities has SQL code that inserts data into the database. I want to open a connection to the database and then use this connection in all the code activities which inserts data into the database (so that they use the same connection).

How do I do this?

You don't have to worry about the costs of creating new connections. ADO.NET transparently handles connection pools for you when connecting to SQL Server . I believe the official Oracle and mySQL drivers do the same for you as well.

As long as the connection strings match, you're in good shape.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM