In this demonstration, we are going to create the sample application. For this, we are going to create a new console application in Visual Studio 2019. We will first connect to our Azure SQL Database account.
Connecting to the Azure SQL database
- Open Visual Studio, and create a new console app (.NET) project.
- Name the project PacktSQLApp.
- Right-click on your project in the Solution Explorer, and select Manage NuGet Packages.
- Select Browse, search for System.Data.SqlClient, and install the package.
- Open Program.cs, and replace the references with the following:
using System;
using System.Data.SqlClient;
- Add the following variable in the Program.cs method:
static string connectionstring;
- Now, go back to the Azure portal. Navigate to the Azure SQL database that we created in the previous section. Under Settings, select Connection strings. Copy the connection string, as follows:
SQL database connection string
- Below...