Trouble connecting to a SQL server using UWP

uwp cannot connect to sql server
windows universal app sql server
sql server connection
uwp connect to mysql
asp net database connection with sql server using c#
unity uwp sqlite
sqlite3 uwp dll
uwp mongodb

I have created a UWP application to try and connect to a SQL Server database hosted on another computer. I'm trying to connect to this server using the code below. However I'm getting what I'm understanding to be a "time out" error when trying to open the connection to the server. I can connect to the server perfectly using an identical connection string on a seperate WPF app.

Some other details about my app: Minimum and maximum version is set to "Windows 10 Fall Creators Update" App is minimum with only a button and label. More details can be provided if needed.

Edit: My question is "Any ideas for why this works fine in WPF but not in UWP using the 'Windows 10 Fall Creators Update' which apparently fully supports SQL server connectivity?"

My UWP app:

using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Navigation;

    using System.Data.SqlClient;

    namespace App2
    {
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
            }

            private void Button_Click(object sender, RoutedEventArgs e)
            {
                {
                    string connetionString = null;
                    SqlConnection cnn;

                    connetionString = @"Data Source=DIMENSIONVRSERV\DIMENSIONVRDB;Database=mydatabase;Persist Security Info=True;User ID=DVRLaptop;Password=password";

                    cnn = new SqlConnection(connetionString);

                    cnn.Open();
                    Lbl_ConState.Text = "Connection Open ! ";
                    cnn.Close();
                }
            }
        }
    }

Error msg:

    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: TCP Provider, error: 25 - Connection string is not valid)
  Source=Core .Net SqlClient Data Provider
  StackTrace:
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at App2.MainPage.Button_Click(Object sender, RoutedEventArgs e) in C:\Users\DVR-Laptop-02\source\repos\App2\App2\MainPage.xaml.cs:line 50

Inner Exception 1:
SocketException: The operation completed successfully

Trouble connecting to a SQL server using UWP, You will need to declare one or both of these capabilities (depending on your networking setup):. enterpriseAuthentication. I have created a UWP application to try and connect to a SQL Server database hosted on another computer. I'm trying to connect to this server using the code below.

After you enabled capabilities enterprise Authentication and privateNetworkClientServer and if not worked, use CheckNetIsolation.exe to verify app that enables the appropriate capabilities .

My workaround I changed the connection string to work TCP/IP , and now works fine!

Connection to SQL Server impossible in UWP app · Issue #25346 , SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or  None of the Ado.Net stuff like data readers, data set, sqlconnection, etc exist in UWP. You can use entity framework to a SQLite data base. If you want to connect to a Sql Server you need to do it through a web service.

Don't forget under Computer Management you may need to enable the TCP/IP Services and restart your SQL Server in order for the services to start working for outside connections to connect remotely to your database.

C# UWP: How to connect to an SQL server for an Universal , G'day guys, In this video I will show you how you can connect directly to a MS SQL Server Duration: 6:47 Posted: Nov 12, 2017 We're using SQL server to store sensor data which I need to read and use in an UWP app to visualize the outcome. The writing program is written in WPF and uses the EF6 which is unavailabel in UWP. Whereas I use System.Data.SqlClient in the UWP app now.

uwp app with sql server Express, https://docs.microsoft.com/en-us/windows/uwp/data-access/sql-server-databases. The sample do not work, it crash with : Cannot connect to  If this connection fails, then you probably have one of the following problems: ping of the IP address doesn't work, indicating a general TCP configuration problem. SQL Server is not listening on the TCP protocol. Go back to the section Enable Protocols. SQL Server is listening on a port other

Using SqlClient in UWP, Data.SqlClient namespace, meaning we can now access Sqlserver databases directly from within our UWP app. This is yet another step in the  Thw goal is to share SQL databases with desktop (WPF) apps and UWP apps. Cannot connect to SQL Server Browser. Sql server 2016 ha been installed via Visual Studio Installer. We fond no way to install the browser. All link for SQL Server 2016 are rerooted to SQL server 2017.

How to build a SQL Connection Dialog in UWP, in UWP that sets up a connection from your app to any SQL Server database Now UWP does not come with an editable ComboBox, so we  Since the Windows Fall Creators Update we can -finally- directly connect to SQL Server from UWP. In that SDK .net core was extended with a large portion of the object model of ye olde ADO.NET , hosted in the System.Data.SqlClient namespace.

Comments
  • Did you add the required networking capabilities in the appx manifest to access this resource?
  • Possibly not. I'm not entirely sure what I'd need to add to the manifest to connect properly and how to add it if so.
  • Edit, no I did not. I just added everything and it works. Do you know which ones I require specifically to connect rather than adding in every capability?
  • I listed those in my answer below