SQL Server 2005 Named Instance Connection Issue

by Cliff 14. January 2008

If you create a named instance in SQL Server 2005 and you receive the message below you should try the following:

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

1. Verify that remote connections are enabled.  You can right click on the instance from SSMS and check the connections section to make sure remote connections are enabled or use the surface area configuration tool.

2. If after verifying that remote connections are enabled, you still can not connect, you should enable and start the SQL Server Browser service using the Surface Area Configuration tool.  Once this service starts, you should be able to connect to the named instance(s). 


Unit Testing and Integration Testing with your database

by Cliff 12. January 2008

I like to do a combination of unit and integration testing with my projects.  When testing code that update the database you need to account for the state of your databse.  If you want repeatable tests, you either need to use stubs or mocks or find a way to return your databse to the state it was in prior to your tests running.

 One approach that I have been using with success is leveraging the System.Transaction name space within my tests that update the database.  Below is some sample code using the NUnit testing framework.  By wrapping the code that updates the database within a transaction (using (...)) the save operation is rolled back:

 /// <summary>
/// Transaction is not "completed" so gets rolled back preventing
/// test data from being persisted to db.
/// </summary>
public void Should_Insert_A_New_Info_Object_Into_DB()
using (TransactionScope transScope = new TransactionScope())
string testDateTime = DateTime.Now.ToString();
Info info = AddTestRecord(testDateTime);
Assert.IsTrue(info.Subject == "Subject: " + testDateTime);
Assert.IsTrue(info.Subject == "Subject: " + testDateTime);



Hope people find this technique useful.

Cliff Gray's Info

Cliff Gray
Developer/Founder GrayTechnology.com.

E-mail me Send mail



<<  June 2017  >>

View posts in large calendar


Download BlogEngine.NET

Download at CodePlex


The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017