Hello
I am using Visual Studio 2008 and SQL Server 2005.
I have a solution that includes an Office Excel 2007 Workbook project and a class library. When I run the Excel form comes up and I am trying to retrieve data from my local SQL Server on clicking a button.
The code I use is
[using (SqlCommand comm = conn.CreateCommand())
{
comm.CommandText = "SELECT * FROM Soldiers";
conn.Open();
SqlDataReader reader = comm.ExecuteReader(CommandBehavior.CloseConnection);]
When I open the connection though an exception is thrown. Look below:
[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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
I have configured the SQL Instance to allow remote connections through the Management Studio and also used the Surface Area Configuration to fix the problem. Still though I receive the error.
I remember this was happening at my work and we could not work for a whole day as we couldn't find a solution. The next day the problem would fix itself. I never had this happening locally though. Have you got any idea why?
I am using Visual Studio 2008 and SQL Server 2005.
I have a solution that includes an Office Excel 2007 Workbook project and a class library. When I run the Excel form comes up and I am trying to retrieve data from my local SQL Server on clicking a button.
The code I use is
[using (SqlCommand comm = conn.CreateCommand())
{
comm.CommandText = "SELECT * FROM Soldiers";
conn.Open();
SqlDataReader reader = comm.ExecuteReader(CommandBehavior.CloseConnection);]
When I open the connection though an exception is thrown. Look below:
[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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
I have configured the SQL Instance to allow remote connections through the Management Studio and also used the Surface Area Configuration to fix the problem. Still though I receive the error.
I remember this was happening at my work and we could not work for a whole day as we couldn't find a solution. The next day the problem would fix itself. I never had this happening locally though. Have you got any idea why?