error: 40 - Could not open a connection to SQL Server
Follow the steps:
*Go to SQL Server Configuration manager
*SQL Server Network Configuration:
*Protocol for MSSQLSERVER
*In the right pane split page you will have to disable VIA as follows
--->Shared Memory - Enable
--->Named Pipes - Enable
--->TCP/IP - Enable
--->VIA - Disable
Or Try the following
Go to Start -> in search type Services.msc
. There you will find services which are available in your system.
There look for -> SQL EXPRESS / SQL Server (SQLEXPRESS)
-> Right click on it -> then Start it .
If it is already in Start. Just Stop and start or simply Restart it.
Comments
-
zana over 1 year
Hi I'm writing a simple console application to save XML data into the database using bulkcopy but am currently having problems connecting to my database.
I am getting a SqlException error:
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. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I have checked for issues ensuring my SQL server is running and that it's configured correctly. Below is my connection string.
string connectionString = @"Data Source=SYAZANA;Initial Catalog=WangSCM;integrated security=true;" ;
I'm at my wits ends trying to figure out the error, what is the mistake that I'm making?