Linking Database VBNet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Accessing Data in a Database through a High Level Language

 When developing a computer based information systems, a high level programming


language such as Microsoft Visual Basic is used to create user interfaces that the user of
the system interacts with.
 For the storage of data in the system there is need to have a database such as My SQL or
Microsoft Access. Therefore, there is need to connect the high level programming
language to the database for the system to be functional.

Connecting Microsoft Visual Basic.Net 2010 to Microsoft Access Database 2007

 Open Microsoft Access Database application.


 Create a database and give it a name of your choice. In this case the name of the database
is Davey_Enterprise_System.
 It is recommended that the database and the Microsoft Visual Basic.Net project should be
stored in the same folder. Therefore, save the database in the same folder you are going to
save your Microsoft Visual Basic project.
 The following shows the Microsoft Access database created using Microsoft Access
2007.
 Open a new project in Microsoft Visual Basic.Net 2010

 Click Project menu when you are using VB.Net 2013 or Click Data menu when using
VB.Net 2010. Then select and click Add New Data Source as shown below:

Microsoft Visual Basic.Net 2013


Microsoft Visual Basic.Net 2010
 Select Database and click Next

 Select Dataset and click Next


 There is need to browse and locate the correct database, in our case, the database is
Davey_Enterprise_System. Therefore, click New Connection.
 Click Browse to locate your database
 Select your database and click Open
 Click on Test Connection to test whether the database was connected successful.
 If connection succeeded, click the OK button adjacent to test connection button.
 The following dialog box is then displayed, verify the name of your database, the one
highlighted.
 Click Next
 Click No on the following dialog box.
 If you click Yes, your database would be duplicated and the copy is stored inside the
vb.net folder. This would cause several problems, including missing the data entered into
the database from the vb.net interface.
 You may change the name of the connection string. If the connection string is ok, click
Next.
 Click to select Tables and Views.
 If need be, one may change the DataSet name, however, the default name is mostly
recommended.
 Click Finish.
 Click View/Other Windows/Data Source if you are using Microsoft Visual Basic.Net
2013 or Click Data/Show Data Sources if you are using Microsoft Visual Basic.Net
2010 or press simultaneously Shift + Alt + D.
 Select the correct data source if you have more than one data sources.
 Click the table you want to link with Microsoft Visual Basic.Net, in this case select
Payment_File.
Click the down arrow

 Click the down arrow on Payment_File as shown below and click Details

Click on Details

 Click and drag the icon to the left of the Payment_File name as shown below. Drag and
release the icon on the form and all the fields from the Payment_File table will be shown
at once.
 The other method is to click and drag each field from the Payment_File separately and
place it on the form.
 If you are using Microsft Visual Basic.Net 2013 when one clicks the details option, the
icon immediately to the left of Payment_File changes from

to

 Drag and drop that icon on the respective form. In this case, the Payment_File form

 Adjust textboxes and labels as required by dragging and resizing them as shown below.
 Run the system, the data in the database is then displayed on the vb.net form.
 Click the Move Next icon and Move Previous to view the next record or previous record
respectively, if any.

Move Previous
Move Next

You might also like