Share connection


Author
Message
Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

Is it possible to share connection for all / certain BOs to connect to DB?



Thank you
Reply
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (938 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Ah, now I get it Smile

By default SQL server will not let you read an uncommited transaction from a table. So when you are in the middle of a transaction, any queries to that table will block and wait for the transaction to commit before going through. This is SQL server functionality (not strataframe), and is working as designed, but there are two ways around it depending on your needs:

1) If you want to go ahead and run the query which will include the uncompleted transaction, you can set the isolation level of SQL to READ UNCOMMITED before running the query, and the set it back to READ COMMITED after the query is run. This will run your query without blocking, but will include the incomplete transaction records.

So execute the following SQL command before running your query:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITED

And when finished, execute this one:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

2) The second option is to leave the isolation level alone, but set the timeout on the query command to a longer value so that it will sit and wait for the transaction to complete before executing. This will include the completed transaction records, but could make the query appear to "hang" from an end user's perspective while it is waiting for the transaction to be completed (you could, of course, show a marquee thermometer or some such as part of the UI to let the user know it is processing.)

For this, you would just set the timeout parameter of your SQL command to a large value before executing it:

'-- Create the command
Dim cmd As SqlCommand = New SqlCommand("dbo.YourStoredProcedureOrQuery")
'-- Increase the command timeout to 5 minutes
cmd.CommandTimeout = 300


 

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search