Updating a Database from WinForms Controls, Old School, Page 2
Figure 2: Configure the Northwind database using settings similar to those shown (noting the use of the Microsoft SQL Server (SqlClient) Data source).
Creating a WinForms Application
WinForms is the catchy name for a Windows application. You can start the Windows application by selecting File|New Project and picking the Windows Forms Application item from the list of templates for Visual Basic.
The New Project items are basically a combination of existing wizards and scripts that play fill-in-the-blanks games with existing template files. This is all part of Visual Studio's extensibility, and if you have followed my column (over the last ten years, or search existing articles), you know that there are extensive articles on extensibility and wizards. There also are detailed examples in several of my books.
On the Form, add two TextBoxes and a button named Insert (see Figure 3). The Categories table has four columns; one is an automatic primary key and the other is an image. You will just update the two text fields. The schema for Categories is CategoryID, CategoryName, Description, and Picture. If you expand the Categories table, click a column, and open the Properties window Visual Studio will let you view the schema information.
Figure 3: A simple form is the basis for everything else.
|Keep it simple if you are just getting started. It will keep your frustration level down and keep you moving forward. The key to progress is to avoid battle fatigue while you are learning new things.|
Point and Click Programming is a Useful Starting Point
RAD (or Rapid Application Development) has a bad reputation, but some things like clicking to generate events is easy to do and helps you make progress while deferring things like wiring delegates (event handlers) manually, as long as you don't defer learning how to wire event handlers forever.
To generate a click event for the Insert button (refer to Figure 3), just double-click it. Add the code in Listing 1 to update the Categories table.