Creating VB database applications using ADO control
21/09/2010 16:38we have learned to build VB database applications using data control. However, data control is not a very flexible tool as it could work only with limited kinds of data and must work strictly in the Visual Basic environment. To overcome these limitations, we can use a much more powerful data control in VB known as ADO control. ADO stands for ActiveX data objects. As ADO is ActiveX-based, it could work in different platforms (different computer systems) and different programming languages. Besides, it could access many different kinds of data such as data displayed in the Internet browsers, email text and even graphics other than the usual relational and non relational database information.
To be able to use ADO data control, you need to insert it into the toolbox. To do this, simply press Ctrl+T to open the components dialog box and select Microsoft ActiveX Data Control 6. After this, you can proceed to build your ADO-based VB database applications.
The following example will illustrate how to build a relatively powerful database application using ADO data control. First of all, name the new form as frmBookTitle and change its caption to Book Tiles- ADO Application. Secondly, insert the ADO data control and name it as adoBooks and change its caption to book. Next, insert the necessary labels, text boxes and command buttons. The runtime interface of this program is shown in the diagram below, it allows adding and deletion as well as updating and browsing of data.
The properties of all the controls are listed as follow:
Form Name | frmBookTitle |
Form Caption | Book Titles -ADOApplication |
ADO Name | adoBooks |
Label1 Name | lblApp |
Label1 Caption | Book Titles |
Label 2 Name | lblTitle |
Label2 Caption | Title : |
Label3 Name | lblYear |
Label3 Caption | Year Published: |
Label4 Name | lblISBN |
Label4 Caption | ISBN: |
Labe5 Name | lblPubID |
Label5 Caption | Publisher's ID: |
Label6 Name | lblSubject |
Label6 Caption | Subject : |
TextBox1 Name | txtitle |
TextBox1 DataField | Title |
TextBox1 DataSource | adoBooks |
TextBox2 Name | txtPub |
TextBox2 DataField | Year Published |
TextBox2 DataSource | adoBooks |
TextBox3 Name | txtISBN |
TextBox3 DataField | ISBN |
TextBox3 DataSource | adoBooks |
TextBox4 Name | txtPubID |
TextBox4 DataField | PubID |
TextBox4 DataSource | adoBooks |
TextBox5 Name | txtSubject |
TextBox5 DataField | Subject |
TextBox5 DataSource | adoBooks |
Command Button1 Name | cmdSave |
Command Button1 Caption | &Save |
Command Button2 Name | cmdAdd |
Command Button2 Caption | &Add |
Command Button3 Name | cmdDelete |
Command Button3 Caption | &Delete |
Command Button4 Name | cmdCancel |
Command Button4 Caption | &Cancel |
Command Button5 Name | cmdPrev |
Command Button5 Caption | &< |
Command Button6 Name | cmdNext |
Command Button6 Caption | &> |
Command Button7 Name | cmdExit |
Command Button7 Caption | E&xit |
———
Back