Problem connecting UWP app (TCP Provider, error: 25)

Salavat 121 Reputation points
2022-11-07T13:10:20.05+00:00

Wrote a small program that uses a connection to SQL Server to create a database, create tables, populate tables, and queries to get data. The main problem occurs at the stage of connecting to the server (if the program is installed through the Microsoft Store, or as unpublished). Internally my program uses a string like "Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;". When I test the program on my personal computer, the connection succeeds and I have the ability to create a database and so on. But after I published the application in the store and installed it on a working computer, an error occurs when trying to connect to the server (for testing, I installed the SQL Server version for developers): "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: 25-Connection string is not valid)".
But the connection string is fine. Checked SQL Server Configuration Manager - Shared Memory , Named Pipes, TCP / ip have the Enabled status.
Used the ability to manually enter the connection string: "Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;" but this option doesn't work either.
What could be the reason? Services associated with the server - work, already tried to restart. Perhaps I am incorrectly determining the IP address, or problems with the port.

Universal Windows Platform (UWP)
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,702 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 100.9K Reputation points MVP
    2022-11-07T22:44:18.667+00:00

    Well, if you have a connection string like

    Server=myServerName\myInstanceName

    And someone downloads the application from the Store in an environment where there is no machine called myServerName, the connection will of course not work.

    You would have to prompt the user for server\instance, or read it from a configuration file, so that the program can run in multiple environments.