Cannot connect to LocalDB (provider: Named Pipes Provider, error: 0 – No process is at the other end
I’m trying to manually connect to LocalDB (both, SQL Server 2019 and SQL Server 2022 services) creating a new application database using ADO.NET (Microsoft.Data.SqlClient).
Everytime I try to connect, I get a generic error telling me that the database file could not be attached.
Error.log:
2024-09-17 19:30:18.40 Logon Error: 15350, Severity: 16, State: 1.
2024-09-17 19:30:18.40 Logon An attempt to attach an auto-named database for file C:TempCvTest.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
2024-09-17 19:31:02.66 Logon Error: 15350, Severity: 16, State: 1.
2024-09-17 19:31:02.66 Logon An attempt to attach an auto-named database for file C:TempCvTest.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Debugging into the Microsoft.Data.SqlClient source code, the following error turned out to be the real reason behind the issue:
A connection to the server could be established, but an error occurred during the
login process. (provider: Named Pipes Provider, error: 0 – No process is at the
other end of the pipe).
What is causing this error?
This is my simple test connection setup. It’s a cheap connection string that every Microsoft sample is quoting:
using SqlConnection con = new SqlConnection(@”Data Source=(LocalDb)MSSQLLocalDB;Integrated Security=SSPI;MultipleActiveResultSets=True;AttachDBFilename=C:TempCvTest.mdf”);
con.Open();
So, it should work off the cuff. But it doesn’t.
Using SSMS, I can easily connect to the LocalDB instance and create/delete databases promptly, even with the provided path.
I already updated from MsLocalDb 15 to MsLocalDb 16, but to no avail.
I’m trying to manually connect to LocalDB (both, SQL Server 2019 and SQL Server 2022 services) creating a new application database using ADO.NET (Microsoft.Data.SqlClient). Everytime I try to connect, I get a generic error telling me that the database file could not be attached. Error.log:2024-09-17 19:30:18.40 Logon Error: 15350, Severity: 16, State: 1.2024-09-17 19:30:18.40 Logon An attempt to attach an auto-named database for file C:TempCvTest.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.2024-09-17 19:31:02.66 Logon Error: 15350, Severity: 16, State: 1.2024-09-17 19:31:02.66 Logon An attempt to attach an auto-named database for file C:TempCvTest.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Debugging into the Microsoft.Data.SqlClient source code, the following error turned out to be the real reason behind the issue: A connection to the server could be established, but an error occurred during thelogin process. (provider: Named Pipes Provider, error: 0 – No process is at theother end of the pipe). What is causing this error? This is my simple test connection setup. It’s a cheap connection string that every Microsoft sample is quoting: using SqlConnection con = new SqlConnection(@”Data Source=(LocalDb)MSSQLLocalDB;Integrated Security=SSPI;MultipleActiveResultSets=True;AttachDBFilename=C:TempCvTest.mdf”);
con.Open(); So, it should work off the cuff. But it doesn’t. Using SSMS, I can easily connect to the LocalDB instance and create/delete databases promptly, even with the provided path. I already updated from MsLocalDb 15 to MsLocalDb 16, but to no avail. Read More