Download presentation
Published byRoland Greer Modified over 9 years ago
1
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali
2
CONTENTS Visual Basic and Database Files ADO Data Control
Viewing a Database File Navigating the Database Updating a Database File © Prepared By: Razif Razali
3
Introduction All business applications need to store large volumes of data organized in a format so that information can be retrieved efficiently and quickly as and when required. With the help of a DBMS (Database Management System), managing the data becomes easy. A DBMS is a system that manages the storage and retrieval of data in a database. Further Microsoft Visual Basic provides tools for creating and accessing a variety of RDBMS (Relational Database Management System). An RDBMS stores and retrieves information according to the relationship defined. In a RDBMS, the data is the container of the tables in which all data is stored in the relationships is formed by data values. A database is a collection of data that is related one to another to support a common application. For example Employee details - Name, Address, etc. Each of these collections of data continue a database. Database accessing methods are as follows; Jet Engine - Accessing Microsoft Access and Visual Basic databases. ODBC (Open Database Connectivity) - Allow access to the client server databases on a network. ISAM (Index Sequential Access Method) - Used to access flat databases such as dBase, FoxPro, ParaDox. © Prepared By: Razif Razali
4
What is Database A database is a collection of information.
This information is stored in a very structured manner. By exploiting this known structure, we can access and modify the information quickly and correctly. The tasks of a DBMS are really quite simple. In concept, there are only a few things you can do with a database: 1. View the data 2. Find some data of interest 3. Modify the data 4. Add some data 5. Delete some data © Prepared By: Razif Razali
5
Data vs information? What is data? What is information?
Data can be defined in many ways. Information science defines data as unprocessed information. What is information? Information is data that have been organized and communicated in a coherent and meaningful manner. Data is converted into information, and information is converted into knowledge. Knowledge; information evaluated and organized so that it can be used purposefully.
6
Why do we need a database?
Keep records of our: Clients Staff Volunteers To keep a record of activities and interventions; Keep sales records; Develop reports; Perform research Longitudinal tracking
7
What is the ultimate purpose of a database management system?
Information Knowledge Action
8
ADODC The ADO (ActiveX Data Object) data control is the primary interface between a Visual Basic application and a database. It can be used without writing any code at all! Or, it can be a central part of a complex database management system. This icon may not appear in your Visual Basic toolbox. If it doesn’t, select Project from the main menu, then click Components. The Components window will appear. Select Microsoft ADO Data Control, then click OK. The control will be added to your toolbox. The icon for ADODC: © Prepared By: Razif Razali
9
Using ADODC Use of ADODC Connect to a database.
Open a specified database table. Create a virtual table based on a database query. Pass database fields to other Visual Basic tools, for display or editing. Such tools are bound tools (controls), or data aware. Add new records or update a database. Trap any errors that may occur while accessing data. Close the database. Refer tutorial URL: © Prepared By: Razif Razali
10
Microsoft Access Object
A Microsoft Access database file, which has an extension of mdb, contains tables, queries, forms, reports, pages, macros, and modules, which are referred to as database objects. That’s a lot of information in one large file, but Microsoft Access manages this data quite nicely. Forms, reports, pages, macros, and modules are generally concerned with letting users work with and display data © Prepared By: Razif Razali
11
Table A table contains a collection of data, which is represented by one or more columns and one or more rows of data. Columns are typically referred to as fields in Microsoft Access, and the rows are referred to as records. Each field in a table represents an attribute of the data stored in that table. For example, a field named First_Name would represent the first name of an employee or customer. This field is an attribute of an employee or customer. A record in a table contains a collection of fields that form a complete set of attributes of one instance of the data stored in that table. © Prepared By: Razif Razali
12
Database Table In this database table, each record represents a single individual. The fields (descriptors of the individuals) include an identification number (ID No), Name, Date of Birth, Height, and Weight. © Prepared By: Razif Razali
13
Table
14
Query A query in a database is a group of Structured Query Language (SQL) statements that allow you to retrieve and update data in your tables. Queries can be used to select or update all of the data in one or more tables or to select or update specific data in one or more tables © Prepared By: Razif Razali
15
Creating a simple database – Using MS Access
Refer Access Tutorial URL: es/2200/access/accessall.html © Prepared By: Razif Razali
16
Steps to Connect a Database
To start using ADODC, you must add ADODC component into your toolbox. Click Project > Components Select Microsoft ADO Data Control 6.0 (OLEDB) © Prepared By: Razif Razali
17
Steps to Connect a Database
Add a Adodc control into Form, examples of Adodc control: Then, by looking at the properties, set the ConnectionString properties, such as Then, click button Build to continue. © Prepared By: Razif Razali
18
Steps to Connect a Database
After clicking Build button, the next steps is to choose a Data Link Properties. Here we choose Microsoft Jet 4.0 OLE DB Provider as our linker. Then, continue this steps by clicking button Next. Here is where we must tell VB the location and name of the database we will be using. © Prepared By: Razif Razali
19
Steps to Connect a Database
Then, select the database file, example: It is always a good idea to use the Test Connection option. This way, if there was something wrong with the location or name of the database, we would get an error advising us of this. If the message inform that the connection is succeeded, it means that your VB have been connected to the database file. © Prepared By: Razif Razali
20
Steps to Connect a Database
After the connection string is built, click OK to dismiss the property pages for the Data Link. Now the control has the information it needs to connect to the data source. However, we still need to inform the data control which table(s) we wish to access. Right click on the ADODC data control again and select ADODCProperties. Notice that the connection string text box is now filled in: © Prepared By: Razif Razali
21
Steps to Connect a Database
Next, Click on the RecordSource tab and click the drop down list box for the Command Type. Select option 2-adCmdTable © Prepared By: Razif Razali
22
Steps to Connect a Database
Now the control knows that we want to access records from a table, and it knows the name of database from when we set up the Data Link. Now, theTableorStored Procedure Name listbox becomes enabled. Click the listbox and all of the tables in the database are shown: © Prepared By: Razif Razali
23
Steps to Bind a Data Source
Assume in the form, there are Textbox which is used to display the informatio in the form. Example © Prepared By: Razif Razali
24
Viewing a database using DataGridView component
The DataGridView component is a container that allows you to bind data from your data source and have it displayed in a spreadsheet-like format, displaying the columns of data horizontally and the rows of data vertically. The DataGridView component also provides many properties that allow you to customize the appearance of the component itself, as well as properties that allow you to customize the column headers and the display of data. URL: © Prepared By: Razif Razali
25
Example – Using DataGridView
© Prepared By: Razif Razali
26
THE END © Prepared By: Razif Razali
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.