Working with a database asynchronously
This recipe walks us through the process of creating a database, populating it with data, and reading data asynchronously.
Getting ready
To step through this recipe, you will need Visual Studio 2015. No other prerequisites are required. The source code for this recipe can be found at BookSamples\Chapter9\Recipe3
.
How to do it...
To understand the process of creating a database, populating it with data, and reading data asynchronously, perform the following steps:
- Start Visual Studio 2015. Create a new C# console application project.
- In the
Program.cs
file, add the followingusing
directives:using System; using System.Data; using System.Data.SqlClient; using System.IO; using System.Reflection; using System.Threading.Tasks; using static System.Console;
- Add the following code snippet below the
Main
method:static async Task ProcessAsynchronousIO(string dbName) { try { const string connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB...