我創建了一個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 關注
- 188 瀏覽
添加回答
舉報
0/150
提交
取消