babboon
babboon

Reputation: 793

vb.net cannot connect to mssql server

I am trying to connect to ms sql server but I get error: provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server.

This is in Windows form application. This application works correct and connects to MSSQL Server in other all other PCs but not in mine. This server is in local network. So I guess problem is not in MSSQL Server.

Before 2 months this application worked on my PC as well, as I coded it with visual studio 2008 and was debugging, all worked great. After that I have installed Visual studio 2012 and MSSQL express 2005 and 2008. So these changes have been made on my PC. Now I go back to edit my application and it cannot connect anymore.

I have searched the web and found that these servers 2005 and 2008 could be the problem. I have removed them both from my PC. Now I have Visual studio 2008 and Visual studio 2012. Could it be the problem for my connection to SQL server? There is no problem with connection to oracle or My SQL.

I cannot remove Visual Studio 2012 as I have code with it. Please help.

Upvotes: 1

Views: 3957

Answers (5)

Vland
Vland

Reputation: 4272

I don't think the problem is about Named Pipes or Visual Studio 2012, especially if other PCs in the network can connect to the server...

  1. have you restarted your SQL server?
  2. can you ping the server from your pc?
  3. have you checked and rechecked the connection string?
  4. can you create a connection to your database using Data Sources (ODBC)?
  5. When you say "Now I go back to edit my application and it cannot connect anymore." do you mean in visual studio, debugging it OR you mean a deployed/installed version of your program?
  6. If you're debugging, are you 100% sure you're trying to connect to the right SQL server and not localhost? I would definitely triple check the connection string and anything related to that

solution: when in doubt, always write your IP address in connection string...

Upvotes: 1

Craig Moore
Craig Moore

Reputation: 1091

From all of the information you have provided I have a concern that this may be your SQL Server Browser service that is pointing you to one of the (now removed) servers that you had on the machine in question. Can you open the remote server from SQL Server Management Studio using the connection details in your web application from this computer?

Upvotes: 0

Al-3sli
Al-3sli

Reputation: 2181

Can you Connect to another server from this PC?
If yes you can then maybe their something in your server prevent your PC from connecting.

if no then their is problem in your PC.

Also try connect using Server IP not instance name.

Upvotes: 0

ɐsɹǝʌ ǝɔıʌ
ɐsɹǝʌ ǝɔıʌ

Reputation: 4512

Google found me this. Please try to perform these instructions an let us know.

UPDATE

To enable named pipes and TCP/IP for Microsoft SQL Server 2005:

Click Start > Programs > Microsoft SQL Server 2005 > Configuration Tools > SQL Server Configuration Manager.

Under SQL Server 2005 Network Configuration > Protocols for MSSQLSERVER:

Double-click the protocol name TCP/IP and set the property ENABLED to Yes.

Double-click the protocol name Named Pipes and set the property ENABLED to Yes.

To restart MS SQL 2005 service, run the following commands in the command prompt window of the Parallels Pro Control Panel server:

net stop mssqlserver
net start mssqlserver

Upvotes: 0

Kirk
Kirk

Reputation: 5077

Mostly the problem will occur due to Firewall issue, did you try disable the firewall and test?

Upvotes: 1

Related Questions