Skip to content

Commit 233c4a1

Browse files
Merge pull request #4895 from MicrosoftDocs/alvinashcraft/main-update-uwp-sqlserver-data-howto
Update SQL Server UWP and WinUI samples
2 parents 7b5ecdd + 9c3219d commit 233c4a1

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

hub/apps/develop/data-access/sql-server-database.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Use a SQL Server database in a Windows app
33
description: Learn how to connect a Windows App SDK app directly to a SQL Server database, and store and retrieve data by using System.Data.SqlClient.
4-
ms.date: 08/01/2024
4+
ms.date: 10/15/2024
55
ms.topic: how-to
66
keywords: windows 10, windows 11, Windows App SDK, SQL Server, database
77
ms.localizationpriority: medium
@@ -18,6 +18,9 @@ In this guide, we'll show you one way to do that in your Windows App SDK apps. I
1818

1919
![Northwind products](images/products-northwind.png)
2020

21+
> [!TIP]
22+
> You can also get scripts to create the **Northwind** and **pubs** sample databases from the [SQL Server Samples GitHub repository](https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/northwind-pubs/readme.md).
23+
2124
The snippets that appear in this guide are based on this [UWP sample app](https://github.com/StefanWickDev/IgniteDemos/tree/master/NorthwindDemo).
2225

2326
## First, set up your solution
@@ -53,14 +56,14 @@ In this section, we'll do these things:
5356

5457
In the **App.xaml.cs** file, add a property to the `App` class, that gives other classes in your solution access to the connection string.
5558

56-
Our connection string points to the Northwind database in a SQL Server Express instance.
59+
Our connection string points to the Northwind database in a SQL Server Express instance. The connection string in this snippet assumes you kept the default instance name `SQLEXPRESS` when installing SQL Server Express. You can make changes to the connection string to match your SQL Server instance, database, and authentication method.
5760

5861
```csharp
5962
sealed partial class App : Application
6063
{
6164
// Connection string for using Windows Authentication.
6265
private string connectionString =
63-
@"Data Source=YourServerName\SQLEXPRESS;Initial Catalog=NORTHWIND;Integrated Security=SSPI";
66+
@"Data Source=.\SQLEXPRESS;Initial Catalog=NORTHWIND;Integrated Security=SSPI";
6467

6568
public string ConnectionString { get => connectionString; set => connectionString = value; }
6669

@@ -216,6 +219,9 @@ Start the project and see products from the Northwind sample database appear in
216219

217220
Explore the [System.Data.SqlClient](/dotnet/api/system.data.sqlclient) namespace to see what other things you can do with data in your SQL Server database.
218221

222+
> [!TIP]
223+
> Try asking [Microsoft Copilot](https://copilot.microsoft.com/) for help with your SQL queries. Copilot can help you write SQL queries, and suggest ways to improve your code.
224+
219225
## Trouble connecting to your database?
220226

221227
In most cases, some aspect of the SQL Server configuration needs to be changed. If you're able to connect to your database from another type of desktop application such as a Windows Forms or WPF application, ensure that you've enabled TCP/IP for SQL Server. You can do that in the **Computer Management** console. (See [Windows Tools/Administrative Tools](/windows/client-management/administrative-tools-in-windows-10#tools) for more information.)

uwp/data-access/sql-server-databases.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Use a SQL Server database in a UWP app
33
description: Learn how to connect a UWP app directly to a SQL Server database, and store and retrieve data by using System.Data.SqlClient.
4-
ms.date: 07/31/2024
5-
ms.topic: article
4+
ms.date: 10/15/2024
5+
ms.topic: how-to
66
keywords: windows 10, windows 11, uwp, SQL Server, database
7-
ms.localizationpriority: medium
7+
#customer intent: As a UWP developer, I want to connect my app to a SQL Server database so that I can store and retrieve data.
88
---
99

1010
# Use a SQL Server database in a UWP app
@@ -15,6 +15,9 @@ In this guide, we'll show you one way to do that. If you install the [Northwind]
1515

1616
![Northwind products](images/products-northwind.png)
1717

18+
> [!TIP]
19+
> You can also get scripts to create the **Northwind** and **pubs** sample databases from the [SQL Server Samples GitHub repository](https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/northwind-pubs/readme.md).
20+
1821
The snippets that appear in this guide are based on this more [complete sample](https://github.com/StefanWickDev/IgniteDemos/tree/master/NorthwindDemo).
1922

2023
## First, set up your solution
@@ -53,14 +56,14 @@ In this section, we'll do these things:
5356

5457
In the **App.xaml.cs** file, add a property to the `App` class, that gives other classes in your solution access to the connection string.
5558

56-
Our connection string points to the Northwind database in a SQL Server Express instance.
59+
Our connection string points to the Northwind database in a SQL Server Express instance. The connection string in this snippet assumes you kept the default instance name `SQLEXPRESS` when installing SQL Server Express. You can make changes to the connection string to match your SQL Server instance, database, and authentication method.
5760

5861
```csharp
5962
sealed partial class App : Application
6063
{
6164
// Create a connection string using Windows Authentication.
6265
private string connectionString =
63-
@"Data Source=YourServerName\SQLEXPRESS;Initial Catalog=NORTHWIND;Integrated Security=SSPI";
66+
@"Data Source=.\SQLEXPRESS;Initial Catalog=NORTHWIND;Integrated Security=SSPI";
6467

6568
public string ConnectionString { get => connectionString; set => connectionString = value; }
6669

0 commit comments

Comments
 (0)