This Getting Started shows how to quickly create a simple application that uses
VistaDB. If you are new to VistaDB, please see Getting
Started Overview in order to gain a broader understanding of how to convert
existing databases to VistaDB. Developing database applications that use VistaDB
is very similiar to using SQL Server.
These instructions explain how to create a basic single form WinForms application
that has a DataGridView component bound to an Employee table from a VistaDB NorthwindEF.vdb4
database.
The following steps are the ones taken in the movie. They are provided here in the
same order presented in the video.
Part 1 - DataSet
- Run Visual Studio 2008
- From the Main Menu, select File -> New -> Project
- From the New Project form, select:
Visual C# -> Windows -> Windows Application -> OK
- From the Main Menu, select Data -> Add New Data Source...
- From the Data Source Configuration Wizard -> Database-> Next
- Click "New Connection" button on the next form
- From the "Add Connection" form, click the "Change" button
- From the "Change Data Source" form, under Data Source, select "VistaDB
Database File" and press OK
- Back on the "Add Connection" form, click the Browse button and select:
"C:\Users\Public\Documents\VistaDB\Databases\Northwind.vdb4"
- Select Open Mode -> Nonexclusive Read Write
- Click "Test Connection" to make sure you can open the database and click
OK
- Back on the "Data Source Configuration Wizard", you should see "VistaDB
Database" for the connection. Click Next
- Rename the connection string "VistaDBConnectionString" and leave the "[x]
Yes, save the connection" box checked. Click Next.
- In the Choose Your Database Objects page, click on the plus sign beside "+
Tables" to see the list of tables in Northwind.vdb4.
- Check "[x] Employees", leave the DataSet name "DataSet1" and
click the Finish button
You just created a new DataSet called "DataSet1" and bound it to the "Employees"
table. In Part 2, you will drop a grid on the form and connect it to DataSet1.
Part 2 - DataBinding
- From the Main Menu, select View -> Toolbox
- Click on All Windows Forms
- Drop the DataGridView component onto the form
- On the top right of the DataGridView component, click on the small arrow icon. This
will display a fly-out drop down toolbar.
- Under "Choose Data Source", select EmployeesBindingSource
- From this same fly-out toolbar, click on Preview Data at the bottom
- From the Preview Data form, click on Preview. This will display the data. Click
Close when done.
- Save and run.
This part builds the forms and binds it to the DataSet you built in Part 1. All
of these steps are identical to how you would perform databinding in SQL Server.