我创建了一个UWP应用程序来尝试连接到另一台计算机上托管的SQL Server数据库。我正在尝试使用下面的代码连接到该服务器。但是,在尝试打开与服务器的连接时,我得到的理解是“超时”错误。我可以在单独的WPF应用程序上使用相同的连接字符串完美地连接到服务器。有关我的应用程序的其他一些详细信息:最小和最大版本设置为“ Windows 10 Fall Creators Update”应用程序最小,只有一个按钮和标签。如果需要,可以提供更多详细信息。编辑:我的问题是“为什么使用“ Windows 10 Fall Creators Update”显然可以完全支持SQL Server连接,为什么在WPF中可以正常工作而在UWP中不能正常工作?我的UWP应用: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(); } } } }
3 回答
江户川乱折腾
TA贡献1851条经验 获得超5个赞
启用功能企业身份验证和privateNetworkClientServer后,如果无法使用,请使用C heckNetIsolation.exe验证启用了适当功能的应用程序。
我的解决方法是将连接字符串更改为可以使用TCP / IP,现在可以正常使用了!
- 3 回答
- 0 关注
- 169 浏览
添加回答
举报
0/150
提交
取消