A network-related or instance-specific error occured 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
The line that the error occurs on is this:
sqlConn.Open();
This is how it looks in my code:
using (SqlConnection sqlConn = new SqlConnection(connectionString))
{
sqlConn.Open();
//more code after this but not necessary for this question
}
My connection string stuff looks like this:
From the C# code file behind the ASP.NET page:
string connectionString = WebConfigurationManager.ConnectionStrings["connectionstringname"].ConnectionString;
From the Web.config file:
<connectionStrings>
<add name="connectionstringname" connectionString="Data Source=localhost;Initial Catalog=databasename;Integrated Security=SSPI" />
<add name="connectionstringnameConnectionString" connectionString="Data Source=servername;Initial Catalog=databasename;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
I have checked the server, and it DOES allow remote access. I am using SQL Server 2005, rather than SQL Server 2008, what I was using on my laptop, where the program worked. Can anyone help? Also I am a bit confused over what an instance is in reference to SQL Server. Is it the name of the server? Or the name of the database? Or the name of the computer the server is on?
Any help is greatly appreciated!

New Topic/Question
Reply



MultiQuote




|