I have a UWP app that needs to connect to a SQL Server Express database. On my dev box, I don't have any issues.
On the client PC, I installed SQL Server Express, created the database, setup the users and logins.
When I run the app, and try to connect to the database, I get an error:
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 instance name is correct and that SQL Server is configured to allow remote connections.
(provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)
The code I'm using to connect is:
...
using (SqlConnection connection = new SqlConnection(ConnectionStringTextBox.Text.Trim()))
{
try
{
connection.Open();
MessageBox.Show("Connected successfully!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
...
Using this same code on a desktop app, on the client machine, the connection succeeds.
I have set up the UWP app to use version 1809 of Windows 10.
The client and my dev box are both version 2004.
Package.appxmanifest
file has the following capabilities checked:
- Enterprise Authentication
- Internet (Client & Server)
- Internet (Client)
- Private Networks (Client & Server)
Windows Firewall has the correct ports open. In SSMS, I have enabled allowing remote connections, enabled TCP.
I don't know what I'm doing wrong or what is going wrong. This same UWP app works great on my dev box.
Any advice is appreciated.