0

I am running a windows application on my computer but, while I connect to my SQL Server database an error occurs which says

Named pipes Error 40 Could not open a connection to SQL server.

I tried several MSDN pages and links, which includes firewall setting change, SQL configuration settings, but nothing works.

Please help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user2038924
  • 3
  • 1
  • 1
  • 3
  • 2
    Missing an lot of context mate. Can you connect via SSMS? Is it an issue with your application alone? Can you connect via the Server explorer in visual studio? – basarat Apr 10 '13 at 06:13
  • Have you viewed the SQL Server Errorlog? http://social.msdn.microsoft.com/forums/en-US/sqldataaccess/thread/c488cf76-2515-440f-b3f8-9cfad689c5b6/ – basarat Apr 10 '13 at 06:14
  • @BasaratAli: Yes my friend. SSMS works fine. But although databases and tables exist in my database the application on run gives the above error. – user2038924 Apr 10 '13 at 06:23
  • And yes...I also checked the SQL server error log. The problem persists. The issue according to me is that the software/windows application works fine on the machine over which it was developed but gives an error when run on some other machine and the server is not found. – user2038924 Apr 10 '13 at 06:24
  • Is the server on the same machine as the one used to develop the software / windows application? – basarat Apr 10 '13 at 06:33
  • Can you please **show us** the connection string you're using? – marc_s Apr 10 '13 at 06:52

5 Answers5

1

SOLVED !! Simply, Instead of using "Microsoft SQL Server (SqlClient)" as The DataSource Use ".NET Framework Data Provider for MySQL" Use your Credentials for the MySQL Connection (ServerName,User,Password,DB-Optional) It should work now.

I've used ADO Entity DATA Model Wizard for My Project and configure .Net as My DataSource. If you have the "error 40..." in different occausion verify your DataSource to the right one.

I tried like most of you to look for Firewall settings, server settings, but it was simple than i thought, so check it out...

For download --->.NET Framework Data Provider for MySQL as your data source/provider:

http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-6.7.4.msi

It worked for me !

1

Search for services in control panel, there you will find Services(Local) in Admin tool section.

select it that will show a window with all services in your system, find your service SQLEXPRESS (MSSQLSERVER) and click on Start.

It should start your server instance.

Mona Kouhi
  • 47
  • 1
  • 2
  • 11
0

please check the SQL Server Configuration Manager

http://msdn.microsoft.com/en-us/library/ms174212.aspx

enable the protocols, mine pipes, tcp and others. and also check the sql browser service is running

Shafqat Masood
  • 2,532
  • 1
  • 17
  • 23
0

The various causes fall into five categories:

1 Incorrect connection string, such as using SqlExpress.

2 NP was not enabled on the SQL instance.

3 Remote connection was not enabled.

4 Server not started, or point to not a real server in your connection string.

5 Other reasons such as incorrect security context.

For more visit

http://blogs.msdn.com/b/sql_protocols/archive/2007/03/31/named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server.aspx

Archit Patel
  • 57
  • 1
  • 2
  • 13
0

In my case the problem was fixed after I "started" "SQL Server(SQLEXPRESS)" under

Computer Management > Services and Applications > Services

Zahra
  • 6,798
  • 9
  • 51
  • 76