.NET Framework: Work with the Console
This sample shows how to create console applications.
Featured Highlights:
The code demonstrates how to create a console application. The console
application uses SQL Server to read the Northwind database
Products table into a dataset. When the console application is run, it accepts
input from the user that is either a product id or 'quit'. If quit is entered,
the console application ends. If a valid product id (integer format) is
entered its associated product information is displayed. If an
invalid product id is entered, an exception message is displayed. Users
can continue to input product id's until quit is entered.
Requirements:
-
Trial or Release version of Visual Studio .NET Professional (or greater).
-
Access to the Northwind database residing in SQL Server or the Microsoft Data
Engine (MSDE). To install MSDE, do the following:
-
Open the Start menu, then click Programs, the click Microsoft
.NET Framework SDK, and then click Samples and Quickstart Tutorials.
-
Click "Step 1: Install the .NET Framework Samples Database".
-
Open a command window, and CD to
\Samples\Setup This is typically : C:\Program Files\Microsoft Visual Studio
.NET\FrameworkSDK\Samples\Setup
-
Type: osql -E -S (local)\NetSDK -i InstNwnd.sql
Running the Sample
Simply press F5.
-
The How To-Work with the Console solution consists of 2 projects. The
startup project is a windows project, How-To Work with the Console, that
displays a windows form which will allow a user launch the actual console
project. The second project in the solution is the console application, How-To
Work with the Console Application, that provides the functionality described in
featured highlights.
See Also:
Building Console Applications,
Console Class,
Debugging Preparation: Console Applications