Database In Visual Basics
Nearly all business application need to store large volume of data, organized in a format that simplifies reterival . This is accomplished(success) DBMS a mechanism for manipulating tabular data with high level command.
V.B provides a wealth of tools for creating and accessing databases on both individual machines and network . The two major tools are :-
- The Data Control => The data control gives you access to databases without any programming . You can set a few properties of the control and use regular control such as to displays the value of the fields in the database.
- Data Access Objects => It is a structure of objects for accessing database through your code. All the functionality of the data control is also available to your code through the data access objects(DAO)
Record Set
Record set are object that represent collection of record from one or more tables .
You cannot access the table of a data base directly. The only way to view or manipulate records is via recordset object. Such record are the result of queries, such as all the customers and the total of the invoices ina given month.
I.D
|
Product
Name
|
Supplied
I.D
|
Enquiry
I.D
|
Quantity
Per Unit
|
|||
1
|
mobile
|
122
|
1
|
10 *2
per
|
|||
2
|
pen
|
231
|
1
|
10*3 per
|
|||
3
|
pencil
|
121
|
2
|
12*3 per
|
|||
4
|
rubber
|
23w
|
2
|
23*23
per
|
|||
5
|
book
|
1234
|
3
|
23*7 per
|
|||
6
|
Charger
|
89
|
4
|
10 *2
per
|
|||
7
|
Tablet
|
77
|
4
|
10*3 per
|
|||
8
|
Laptop
|
78
|
5
|
12*3 per
|
|||
9
|
Chair
|
6
|
6
|
23*23
per
|
|||
10
|
Ring
|
55
|
6
|
23*7 per
|
|||
11
|
Computer
|
45
|
7
|
10 *2
per
|
|||
12
|
Laptop
|
44
|
8
|
10*3 per
|
|||
13
|
Mobile
|
44
|
8
|
12*3 per
|
|||
14
|
Ram
|
33
|
9
|
23*23
per
|
|||
15
|
Pendrive
|
22
|
9
|
23*7 per
|
|||
16
|
Floppy disk
|
12
|
9
|
23*1 per
|
A record set therefore is a view of some of the data in the data base , select from the database according to user specified criteria. The three types of record set are as follow :-
- Dyna set which are updatable view of data.
- Sapshots , which are static (read only) view of data.
- Tables , which are direct view of tables.
Data Control
Record set are the foundation of data base programming. The data1 application is nothing less than a front end for an existing table in databases.
Vb6 at work : The data1 project
To build this , follow these steps:
- Start a new standard exe project and design a form like the one . Start by drawing a data control at the bottom of the form.
- With the data control selected , open the properties window, locate its database name property , and then click on the ellipsis button to open the open dialog box.
- Select the NWIND database that comes with V.B.
- Locate the RecordSource in the properties window, and dropdown the list of available enteries . You will see a list of all the tables in the NWIND database . Select the customer table.
- Place four textbox on the form.
- Select the first textbox and in the properties window locate its data source property . Set it to data1.
- Set the field property of the textbox to company name . The data field property is a dropdown list with the names of the fields in the customer table.
- Set the data source property of the other three textboxes to data1 and set the datafields property to country , phone, and fax.
Data Control Property
- Database Name = It can specifies the database to be used.
- Record Source = It can specifies the part of the database seen by the control.
- Data Bound = The text box control see a field in the current row .Each time the control is repositioned in its record set,the textboxes are updated . If the data in the textbox change , the new value is written to the database when the data control is repositioned. The text box control are connected to a field of a record set through the data control , are called data bound.
- Data source = It is the name of a data control through the control.
- Data fields = It is the name of a field in the record set that the control displays and update.
- Eof = The EOF(end of file) property return a true/false values that indicates whether the current record position is after the last record in the record set ojects.
- Bof = The BOF (begnings of file) property a T/F value that indicates whether the current record position is before the first record in a record set.
- Bof Action = This property sets or return a value indicating what action the matter control should take when the BOF property is true , can be one of the action.
- Eof Action = This property sets or return a value indicating what action the data control should take when the BOF property is true , can be one of the action.
- Read only = This property return or sets a value that determines whether the control record set is opened for read only access.
- Record set type = This property return or sets a value indicating the type of record set objects you want the data control to create.
- Option = This property set one or more characteristics of the record set objects and can be have one of the values.
- Bookmarks = This property is a varients that identifies a row in the recordset . Each row in the record set.Each row has its own, unique bookmark that is not related to the record order in the record set.
Data Control Methods
- Move First = Reposition the control to the first record.
- Move last = Reposition the control to the last record.
- Movepre = Reposition the control to the previous record.
- Move next = Reposition the control to the next record.
0 comments:
Post a Comment