Database project
 

  


Download Access Database for this project



Click File > New Project from the menu bar



  • Select Windows Application, and then give it the Name AddressBook. Click OK


  • Locate the Solution Explorer on the right hand side (If you can't see it, click View > Solution Explorer from the menu bar.

We need to select a Data Source. So click on Data Sources at the bottom of the Solution Explorer:




 


To Add a New Data Source, click on the link.
Use Data Source Configuration Wizard,

click Next, to get to the screen below:



 

 


In the next step, you have to tell the Wizard where your database is.


click the Browse button, and navigate to your Access Database Then click Next.

The Wizard will then take a look at your database, and display all your tables, fields amd objects. if you downloaded our database, you Wizard should look something like this:



 


Click the Tables box, and all of the other items will have ticks in them. Notice the DataSet Name: AddressBookDataSet. You'll learn just what a DataSet is in a later section. For now, just click the Finish button.


When you click Finish, the Wizard goes to work. When it's done, it looks as though not much has changed. But notice the Solution Explorer:



 


The Data Sources area of the Solution Explorer now displays information about your database. Click the plus symbol next to tblContacts:



All the Fields in the Address Book database are now showing. In the next part, we'll see how to add these fields on to the Form.



click Data from the menu bar. Then click Show Data Sources):

 

To add a Field to your Form, click on one in the list. Hold down your left mouse button, and drag it over to your form:

 


 

When your Field is over the Form, let go of your left mouse button. A textbox and a label will be added. There's two other things to notice: a navigation bar appears at the top of the form, and a lot of strange objects have appeared in the object area at the bottom:


 

notice the Navigation bar in blue. Run your programme by hitting the F5 key on your keyboard. You should see this:


Click the Navigation arrows to scroll through the database.When you've played around with the controls, stop the form from running, and return to Design View.

  
 

Drag and Drop more Fields to your form. But don't align them yet. We'll see an easy way to do this. But once you've dragged the fields to your form, it might look like this:


 


 

there's a very easy way to align all your controls. Try this:


  • Click on a Textbox with your left mouse button


  • Hold down the Ctrl key on your keyboard, and select a second Textbox


  • With the Ctrl key still held down, click each Textbox in turn


  • When all Textbox are selected, click on the Format menu at the top


  • From the Format menu select Align > Lefts. The left edges of the Textboxes will align themselves


  • From the Format menu select Vertical Spacing > Make Equal. The space between each textbox will then be the same

With your new controls added, and nicely aligned, press F5 to run your form. You might have something like this:



 

 

(c) Shilpa Sayura Foundation 2006-2017