Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql Command Timeout
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 1.1
OS:
Windows XP
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01043997
Message ID:
01246631
Views:
23
Jim,

>The tips in the help file for globally changing the Command Timeout were very useful and easy to do because there is a CommandTimeout property on the dao class. Is there a way to globally change the isolation level of SQL Server too? The default isolation level for SQL Server is READ COMMITTED. I would like to globally change that level so that there is not so much SQL locking in my application.
>
>Hint: SQL help says that there are two common ways to set the isolation level.
>1. Run the SET TRANSACTION ISOLATION LEVEL Transact-SQL statement every time you open a connection.
>2. ADO.NET applications using the System.Data.SqlClient managed namespace can specify an IsolationLevel option using the SqlConnection.BeginTransaction method.

We don't have a specific setting for this (but I'll add it to our hit list for the next version). We have to performa few different steps because the transaction object's IsolationLevel property is read-only. So for now, you can create a subclass of mmDataAccessSql (for example, myDataAccessSql) and override the BeginTransaction() method like this:
public override void TransactionBegin(out IDbConnection conn, out IDbTransaction trx, out bool connOpen)
{
	connOpen = false;

	// Create a connection if one doesn't exist
	if (this.Connection == null)
	{
		this.Connection = this.CreateSqlConnection();
	}

	// Open the connection if it's closed
	if (this.Connection.State == ConnectionState.Closed)
	{
		this.Connection.Open();
		connOpen = true;
	}

	// Create the transaction object
	this.Transaction = this.Connection.BeginTransaction(IsolationLevel.ReadUncommitted);

	// Set the output parameters
	conn = this.Connection;
	trx = this.Transaction;
}
You then need to override the CreateDataAccessSql() method of your application's Factory class like this:
public override mmDataAccessSql CreateDataAccessSql()
{
	return new myDataAccessSql();
}
If you have created custom data access classes (that retrieve and update data using stored procedures) you need to change the base class of these data access classes to myDataAccessSql. Also, if you are using custom data access classes, then then next time you run the Business Layer Generator, specify the base data access class as myDataAccessSQl rather than mmDataAccessSql.

Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Reply
Map
View

Click here to load this message in the networking platform