UWP cannot connect to local SQL Server

1

I'm creating a simple UWP application working together with my local DB server I set up with SQL Server Management Studio.

I can successfully set up a connection in the server explorer and run queries in the DB:

SERVER EXPLORER

However when I run the application I get an error when the connection is being established:

CONNECTION ERROR

System.Data.SqlClient.SqlException HResult=0x80131904 Message=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: SQL Network Interfaces, error: 25 - Connection string is not valid) Source=Core .Net SqlClient Data Provider

I'm not sure if it's a problem with the connection string or what else it could be. I checked the firewall settings and everything seems to be fine. The SQL server settings also allow for remote connection.

sql-server
uwp
asked on Stack Overflow Jul 28, 2020 by M11CH • edited Jul 28, 2020 by M11CH

2 Answers

0

Which SQL Server version is running?

Have you tried with the following connection string format?

Data Source=.\\MSSQLServer;Initial Catalog=PapaDario;Trusted_Connection=yes;
answered on Stack Overflow Jul 28, 2020 by Krusty
0

Before you connect to your database, some aspect of the SQL Server configuration needs to be changed. First, ensure that you've enabled TCP/IP for SQL Server. You can do that in the Computer Management console. Then make sure that your SQL Server Browser service is running.

answered on Stack Overflow Aug 3, 2020 by Faywang - MSFT

User contributions licensed under CC BY-SA 3.0