'How to deploy c# app to another PC and have it connect to that PCs (pre existing) local database
Summary: My C# Winforms app, deployed to another PC, is failing to connect to the local database on that PC (SQL Server Express). It works fine on my PC, which has the same version of SQL Server Express and an identical copy of the database. The only thing I have altered in the deployed version is the connection string, which I retrieved from the target PC by creating a udl file.
I have a C# Winforms app that connects to a local database in SQL Server Express, using this connection string in the app.config file (in Visual Studio):
providerName="SQLOLEDB.1"
connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DatabaseName;Data Source=MYServerName\SQLEXPRESS"
This works without any issues on my PC.
However, I would like to deploy this app to another PC, which already has the same version of SQL Server Express and an identical copy of the database.
I retrieved the connection string information from the target PC(by creating a .udl file and copying the contents) and put this new connection string in the app.config file in Visual Studio (I retrieved the connection string for my working version with the same method)
Target PC connection info:
providerName="SQLOLEDB.1"
Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DatabaseName;Data Source=TARGETserverName\SQLEXPRESS
However, when I publish the app and install it on the target PC, it runs but fails to connect to the db. I get this error:
(Provider SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Unhandled exception has occurred in your application... 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 name is correct and that SQL Server is configured to allow remote connections.
The server and database are local on the target PC so it is not a network issue. The connection string was retrieved from the target PC with a .udl file, which tested the connection and deemed it successful. the target PC has the appropriate version of .net installed (v4.0). The only difference between my PC and the target PC is the target does not have Visual Studio installed, which I would like to avoid.
What am I missing? Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
