简体   繁体   中英

C# - Named Pipes Provider, Error: 40 - local access

I developed a windows application on another system, SQL Server was located somewhere on another server, standard instance, data access was not a problem at all.

Now I have to do some work on the application on my own system, where I have a Standard SQL Server on the same machine and an identical copy of the database. The database is perfectly accessible from the outside, testing the connectionstring from C# succeeds. I tried access using my windows user as well as SQL authentication using sa and its password. All test succeed, but when I try to run the application it fails giving the error message:

...Named Pipes Provider, Error: 40..

I am using SQL Server 2019, standard port, all protocols activated. The users I tried are sysadmins (since I only want to make some modifications to my application, security is not important at the moment).

It looks as if I had no local access to my database from a C# application - I am using Office 365. Any idea what I can do to make my application work locally? Thanks so much!

Check this troubleshooting guide from MS even when it says it's for connecting to instances on a different host.

If you already validated that all protocols are enabled, you should check the connection string you're using. You can try the following:

  • Specifying localhost or the host name will use shared memory so you shouldn't get any error related to named pipes.
  • Use the pipe path (you can find it in the SQL Server Configuration Manager - > SQL Server Network Configuration -> Protocols for -> Named Pipes -> Properties -> Pipe Name
  • Use the IP of the host and specify the port number (1433 if it's the default one)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM