Friday, February 24, 2012

Error 26: When connecting to Local Server with SQL Server 2005 Standard Edition

Hi,

I've been trying to fix this error for two days! and I really need the advice of the experts please!

Computer XP Professional Service Pack2, SQL Server 2005 and Visual Studio 2005 (both Standard Edition)

ConnectionString:

<connectionStrings>

<add name="MyConnectionDB" connectionString="Data Source=(MyServer\SqlServer2005);Initial Catalog=MyDB;User ID=sa;Password=PasswordforSA" providerName="System.Data.SqlClient" />

</connectionStrings>

C# code

string

myConnectionString = ConfigurationManager.ConnectionStrings["MyConnectionDB"].ConnectionString;

SqlConnection myConnection = new SqlConnection(myConnectionString);

myConnection.Open();

Here I get the error: {"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)"}

What I checked so far:

ServerName and Instance Name OK! Database, Username and password OK! SQL Server 2005 Surface Are Configuration - Remote connections using both TCP/IP and Pipe Names OK! SQL Configuration Manager - Protocolos Enabled (TCP/IP, Pipes, shared) OK! SQL Server Browse running and active OK! No Firewall

Am I missing something? I never had this problem with SQL Server 2000 and Visual Studio 2003.

Thanks in advance for any help or suggestion you can give me.

Sasa

Hi there,

I have managed to replicate your problem on my machine. I also managed to resolve it by removing the brackets, i.e. the "(" and ")", from the name of your data source.

So, your connection string would be:

<add name="MyConnectionDB" connectionString="Data Source=MyServer\SqlServer2005;Initial Catalog=MyDB;User ID=sa;Password=PasswordforSA" providerName="System.Data.SqlClient" />

Before removing the brackets I got the same errors you were getting. After removing the brackets I could connect successfully.

Have a go at removing the brackets and see if that works for you.

Hope this helps, but sorry if it doesn't
|||

You are my hero!!!

I don't know how many times I checked that connectionstring, I was thinking it was any configuration setting.

Thanks a lot

|||Where do I go to remove the "()"?|||

you need to open de Web.config file in the <connectionStrings> section

Sasa

|||

Hi

I thought it is a joke to remove the "()" but it works, You are my hero.

barak

No comments:

Post a Comment