Visual Basic 2005


Add to MY Favorites...

Back to Vicky's Home Page Teaching Home Page Visual Basic 2005 Html For Kids

Adding a Data Base

Add an Access Database to a VB 2005 project.

  • Data menu, click Add New Data Source

 

 

  • The Data Source Configuration Wizard will start.

  • Click the Database icon.

  • Click Next.

 

 

  • Click New Connection.  Next will become enabled.

  • Click Next.

 

  • The following screen will appear.  The connection uses a local file which is not in the project.  The file will be copied into the project.

  • Click Yes.

 

  • Click Microsoft Access Database File

  • The Data Provider automatically fills in.

  • Click Next.

 

  • Click browse and find the file

  • Click test connection.

  • Click OK.

     

  • The database file will appear in the list box.

  • Click Next.

 

 

  • Click Yes to save the connection.

  • Type in a name for the connection.

  • Click Next.

 

  • Click the plus boxes to drop down the list.

  • Select the objects you will need in your Visual Basic project. These will be called the DataSet.

  • You can click the fields individually, or select the entire table by clicking the check box left of the table name.

  • Type in a name for this DataSet.

  • Click finish.

  • Save the project.

When you return to the IDE, the Solution Explorer will hold three new items.

It will now shares its space with the Data Sources window.  There are tabs at the bottom to switch between the windows.

If Data Sources are not combined in the Project Solution window, pull down the Data menu, and choose Show data sources.

Add Control Objects To The Form

  • Display the form.

  • Display the Data Sources by clicking the tab at the bottom.

  • Click the DataSet to see its elements.

  • Click on the field name, then drag and drop it onto the form.

After you drop the first DataSet field into the form object, the data base controls will appear at the top of the form, and three new form controls will appear in the component tray under the form.

  • Click and drag the remaining fields you need onto the form.

 

Loading Masked Edit Text Boxes

  • To use a Masked Edit text box.

  • Drag the object from the toolbox onto the form.

  • Set the mask.

  • Drag and release the field from the Data Source window into the mask object.

 

Using the Data Base Controls

  • Use the forward and back buttons to move one record at a time through the data base records. When you are at the first record, the back button is not active. The forward button is not available when you are at the last record.

 

  • Use the first and last record buttons to move to the first and last records in the set. The last record is blank.

Without further modification, no changes made through this control will affect the actual data base.  This is a copy of the data base. The following explainations will only make changes to the copy.

  • To add a record, click the Last button. The fields will appear blank on the screen.  Enter the new data.  Click the Add button when you are done.

 

  • To delete a record, display the record, then click the delete button.

Create a Query

  • Click the textbox for the field you want to search with.

  • Pull down the Data menu, choose, Add Query

 

  • The Search Criteria Builder will appear.

  • Choose New Query and give it a name. No spaces are allowed in the name.

  • Click Query Builder DON’T click OK yet.

 

  • In the Query Builder window, construct the query.

 

 

  • Click the Execute query button to see a preview of your work.  If the query results are what you intended, click OK until you are out of the Query Builder..

 

  • When you run the project in debug mode, a tool bar will appear with the query listed on it.  Click the query name to run the query.

 


 
Another page developed by
vicky@vickywoodard.com
Copyright © 2006 Vicky K. Woodard
All rights reserved
Last updated: 8/17/2006