You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hub/apps/develop/data-access/mysql-database.md
+19-3Lines changed: 19 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
---
2
2
title: Use a MySQL database in a Windows app
3
3
description: Learn how to connect to a MySQL database from your Windows app, and test your connection using sample code.
4
-
ms.date: 08/01/2024
4
+
ms.date: 01/23/2025
5
+
ms.collection: ce-skilling-ai-copilot
6
+
ms.custom: copilot-scenario-highlight
5
7
ms.topic: how-to
6
8
keywords: windows, windows app sdk, MySQL, database, uwp, wpf, winforms, windows forms, winui
7
9
ms.localizationpriority: medium
@@ -21,6 +23,9 @@ This example can be used with any WPF, Windows Forms, WinUI 3, and UWP project t
21
23
22
24
This will allow you to programmatically access MySQL databases.
23
25
26
+
> [!NOTE]
27
+
> [MySQL Connector/NET](https://dev.mysql.com/downloads/connector/net/) version 6.4.4 or later is required to use the `MySql.Data` package with Windows authentication.
28
+
24
29
## Test your connection using sample code
25
30
26
31
The following is an example of connecting to and reading from a remote MySQL database. Note that the server address and database name will need to be customized.
@@ -46,8 +51,19 @@ using (var mySqlCn = new MySqlConnection(M_str_sqlcon))
46
51
> [!IMPORTANT]
47
52
> In production applications, connection information should be stored securely in app configuration (see [**Adding Azure App Configuration by using Visual Studio Connected Services**](/visualstudio/azure/vs-azure-tools-connected-services-app-configuration)). Connection strings and other secrets should not be hard-coded.
48
53
49
-
> [!NOTE]
50
-
> [MySQL Connector/NET](https://dev.mysql.com/downloads/connector/net/) version 6.4.4 or later is required to use the `MySql.Data` package with Windows authentication.
54
+
## Building a connection string with GitHub Copilot
55
+
56
+
You can use GitHub Copilot to build the connection string for your MySQL database. You can customize the prompt to create a connection string per your requirements.
57
+
58
+
The following text shows an example prompt for Copilot Chat that generates a connection string similar to the one shown in the previous code snippet:
59
+
60
+
```copilot-prompt
61
+
Show me how to create a MySQL connection string to a server named myServerAddress and a database called myDatabase. Use Windows authentication.
62
+
```
63
+
64
+
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
65
+
66
+
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
0 commit comments