I am trying to connect to a SQL Server database with appconfig but however I am getting the following error:
"An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll".
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.Named Pipes Provider, error: 40 - could not open connection to sql server.
Here is my code:
SqlConnection conexion = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conectar"].ConnectionString);
the error is happening on the line: conexion.Open();
Appconfig:
<connectionStrings>
<add name ="conectar" connectionString="server=servername;Integrated security=yes; Database=Base01"/>
</connectionStrings>
the error is happening on the line: conexion.Open();