我在尝试从UWP应用程序连接到SQL Server时遇到错误,我已经激活了这些功能:
代码如下:
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 App1544
{
/// </summary>
public sealed partial class MainPage : Page
{
const string ConnectionString = "SERVER = DESKTOP-DI0OR53; database= DBNAVEGANTE; user id= root; password = a";
public MainPage()
{
this.InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
using(SqlConnection con = new SqlConnection(ConnectionString))
{
con.Open();
label1.Text = con.State.ToString();
}
}
}
}