Red Gate forums :: View topic - Setting the transaction isolation level
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK 10
SQL Comparison SDK 10 forum

Setting the transaction isolation level

Search in SQL Comparison SDK 10 forum
Post new topic   Reply to topic
Jump to:  
Author Message
zacuke



Joined: 15 Jan 2013
Posts: 3

PostPosted: Wed Jun 04, 2014 3:55 pm    Post subject: Setting the transaction isolation level Reply with quote

How does one tell SQL Compare SDK to use a different transaction isolation level?

I am fighting with the error "Transaction context in use by another session." There is a setting in the SQL Compare GUI, but how do I use that setting in the SDK?

How do I ensure the setting is applied when the code is ran on a computer that does not have the GUI installed?

Possibly I could manually String.Replace the script before executing, but that is not apparent how to perform the string replacement either.

EDIT: I was able to figure out how to modify the script, but is this the best way to do this?

Code:
using (var block = work.ExecutionBlock)
            {
                String myscript = block.GetString();

                myscript = myscript.Replace("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE", "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");

                using (var myblock = BlockLoader.LoadFromString(myscript))
                {
                    if (settings.SqlServerUserName == "")
                    {
                        blockExecutor.ExecuteBlock(myblock, stagingDBConnectionProperties.ServerName, stagingDBConnectionProperties.DatabaseName);
                    }
                    else
                    {
                        blockExecutor.ExecuteBlock(myblock, stagingDBConnectionProperties.ServerName, stagingDBConnectionProperties.DatabaseName, false, stagingDBConnectionProperties.UserName, stagingDBConnectionProperties.Password);
                    }
                }
            }
[/code]
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6677

PostPosted: Thu Jun 05, 2014 4:24 pm    Post subject: Reply with quote

There is a "TransactionIsolationLevel" property on the "Work" object that you create to do the scripting. Have you tried setting that property to "READ UNCOMMITTED"?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group