Visual basic allows us to manage databases created with different database programs such as MS Access, Dbase, Paradox and etc.
Creating VB database applications using ADODC Data Control
Data Control
The Data Control also can be used to connect databases. The previous versions of Visual Basic 5.0 used this control. That control is still included with Visual Basic 6.0. But it does not support databases created after Ms Access 97.
To overcome these limitations we can use a much more powerful data control in VB known as ADO Control.
Adodc 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………… do as follows
Click Component on the project menu
Click Microsoft ADO Data Control
Click Apply Click Ok
When a Adodc control is placed on a form, it appears with the assigned caption and four arrow buttons:
The arrows are used to navigate through the table rows (records). As indicated, the buttons can be used to move to the beginning of the table, the end of the table, or from record to record
The Adodc can be used to perform the following tasks
Connect to a database.
Open a specified database table.
Record operation (Add new records or update a database)
Close database
Data Control Properties
ConnectionString :Contains the information used to establish a connection to database.
RecordSource
etermines the table that ADO Control is attached to.
A Database has already been created in the hard disk.
The name of the database is “TP”
The Name of the table (Recordset) is “Numbers”
Now lets connect the database step by step…….
The Design Interface
Select the Adodc1 control and its Property Window
Next select the database
Select “Use Connection String
Then Select Microsoft Jet 4.0 OLE DB Provider
Click here to connect the database
Next the relevant Database & open
After entering the database , Test it.
Finally Apply it & press OK.
Next connect the relevant table (Record source) from the Linked database
Next, from the command type, select table command type.
Next, from the “Table or Stored Procedure Name” select name of table.
Next, from the “Table or Stored Procedure Name” select name of table.
Finally Apply it & press OK.
Once the ADO data control is connected to a database, we need to assign a table to that control. Recall each data control attached to a single table, whether it is a table inherent to the database or the virtual table we discussed. Assigning a table is done via the RecordSource property.
Now We need to bind text boxes to the data control for the application to work. To do this, open the text box’s DataSource and select data_navigator that will appear automatically.
One more thing that we need to do is to bind the text box to the correct field so that data in this field will appear on this text box. To do this, open the Data Field property and select Name.
Design Interface
Select the text1 & Open the property window. There Select Data Source as ADODC1
& from DataField property, select relevant data field that text1 represents.
Now, press F5 and run the program. You should be able to browse all the names by clicking the arrows on the Adodc1 control.
The ADODC control support some methods that are useful in manipulating the database, for example, to move the pointer to a certain location. The following are some of the commands that you can use to move the pointer around.
@
Finding Specific Records
In addition to using the data control to move through database records, we can write Visual Basic code to accomplish the same, and other, tasks. This is referred to as programmatic control..
There are four methods used for moving in a database. These methods replicate the capabilities of the four arrow buttons on the data control:
MoveFirst Move to the first record in the table.
MoveLast Move to the last record in the table.
MoveNext Move to the next record (with respect to the current record) in the table.
MovePrevious Move to the previous record (with respect to the current record) in the table.
We will develop a simple DBMS. It will allow us to view records in an existing database. We will be able to edit records, add records, and delete records.
To create our DBMS, we need to define a few more programmatic control methods associated with the Adodc Recordset property. These methods are:
AddNewA new record is added to the table. All fields are set to Null and this record is made the current record.
Delete The current record is deleted from the table. This method must be immediately followed by one of the Move methods
because the current record is invalid after a Delete.










i amnot satisfy
By: m.azizul hasan on September 16, 2008
at 5:13 am
can u tell me what are the ff menus to click in Access to create relationship on Visual Basic? Thru Adodc1
step by step pls…
By: blehbleh on October 14, 2008
at 5:47 pm