System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) at ftp_controls.Common_.Utility_.GetCustomRegPropertiesByUrl(String url) Visual Studio Magazine - ASP.NET - Use Caching to Enhance Performance
Welcome Guest!
Create Account | Login
Locator+ Code:

FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Click here to receive your FREE subscription to Visual Studio Magazine

email article
printer friendly
more resources

Use Caching to Enhance Performance
Take advantage of the .NET Framework's caching functionality to build high-performance, enterprise-ready Web apps.
by Jonathan Lurie

Technology Toolbox: VB.NET, ASP.NET

Enterprise Web applications must be capable of providing good response times, despite having thousands of concurrent users. Server-side caching is one of the most effective means of achieving high levels of performance. I'll explain how to take advantage of the caching functionality within the .NET Framework.


Caching entails placing commonly requested resources, such as product lists and files, into an area in memory where they are accessible quickly, thereby optimizing response times. The performance benefit is significant, because the resource doesn't need to be re-created or retrieved from the database the next time it's requested (see the sidebar, "Don't Confuse Performance With Scalability"). Consider a product list with hundreds of items in it. The application's response time will be relatively slow if it must hit the database every time a user requests the list. This is unnecessary when the product list doesn't change between requests (see Figure 1).

Figure 1. Reap the Benefits of Caching.

ASP.NET has two caching techniques you must be familiar with in order to build enterprise-ready applications: the Cache object and the output cache. You can use the Cache object to store individual values, such as a file or a computed number. You can use the output cache to store entire ASP.NET pages and user controls. These techniques are significantly different from each other and require individual attention. I'll focus only on the Cache object.

The .NET Framework exposes a class named Cache, which resides in the System.Web.Caching namespace. ASP.NET creates one cache per Web application, and the cache isn't shared across multiple applications. You should use the Cache object for caching, even though many developers use the Application object instead. The Cache object is quite similar to the Application object, in that they both use a key-value pair to store variables. However, the Cache object is tailored for caching, because it supports object expiration from the cache. This is important because as you place more and more resources into the cache, your application begins to consume more and more memory. This has an adverse effect on performance and can even negate any benefit you derive from caching. Expiring objects removes them from the cache. Although no caching solution can implement all available algorithms for determining what should stay and what should go, Microsoft has done a good job of providing you with several alternatives. The Cache object is also different from the Application object in that it implements automatic locking, which means you don't need to worry about concurrent access; you must use an Application.Lock() with the Application object.

Back to top

Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home