Click here to Skip to main content
15,877,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I buid to my computer SQLSERVER 2012 Exspress. I can connect to my database with Microsoft Sql Server Management Studio with windows Authentication and Sql Server Authentication.
But when ı try to connect with my ASP.net application ı get this error message:
"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 read the lots of solution but ı can not access.

Thanks for your answers
Posted
Comments
Richard C Bishop 18-Sep-13 12:47pm    
Show the code.
Mehdy Moini 18-Sep-13 12:49pm    
What is your connection string?
do you allow remote connections?
al maze 18-Sep-13 13:36pm    
i think that when you're running an asp.net app (IIS) the NT auth account connecting to sql server is that from which the web server runs under. local system/nt auth/aspnet. also check the application pools (identities) under which the code runs in the webserver.
hope this helps
Subhabrata Bose 18-Sep-13 14:07pm    
check sql server inbound firewall rules
sabridemirel 18-Sep-13 15:12pm    
Thank for replies.I try two different connection string:
SqlConnection connection = new SqlConnection("Data Source=localhost;Initial Catalog=SABRI-PC\SQLEXPRESS;Integrated Security=True");
SqlConnection connection1 = new SqlConnection(@"Server=localhost;Database=SABRI-PC\SQLEXPRESS;User ID=sa;Password=Sd0226535;Trusted_Connection=False;");
I allow the remote connections.
I completly turn off my firewall.

If you are running on Win7, try to restart the SQL server.
Open the task manager (ctrl+shift+esc).
Select the Services Tab.
Click on the bottom button 'services'. This will give you all rhe running services on the machine.
Locate MSSQLSERVER.
Click on Start or Restart.

I think this should solve the problem
 
Share this answer
 
Comments
sabridemirel 19-Sep-13 5:07am    
Thanks, solved problem
In SQL Server Configuration Manager, go to "SQL Native Client (version) Configuration" - Client protocols and activate shared memory, TCP/IP, named pipes.
If applicable, do that for both "32 bit" and "64 bit" sections.
Restart your SQL Server, and try again.
Also make sure that the account of the IIS has access rights to your database (you may temporarily for testing purposes run IIS with your user account - do not do that in production!).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900