ODBC USING ADO ( ACTVEX ADO CONTROL) | RETRIEVE THE RECORDS FROM THE ORACLE DATABASE TABLE USING ADO

AIM :
To interface with the OLEDB though an active data objects and access a wide variety of data source.

PROCEDURE:
1. To retrieve the records from the oracle database table (say customer table)
1. Using (say customer table) using ADO, the following steps are followed.
2. Start visual basic 6.0 and choose standard EXE project
3. Through project menu, component field select Microsoft ADO data control which adds control to the toolbar.

4. Right click the ADO data control and choose ADODC properties and select the use odbc DATA SOURCE NAME and set the table name.
5. In the property page, choose the record source property to specify the name and the table.
6. Then select the record source.
7. In the command type list box choose option 2 and command table and set the table name.
8. Select customer table from the table place a text box name text1 and set its database properties ADODC1.
9. Now set the data field as ADODC1 and the data field property is set to customer name
10. In the similar way include two or more text controls and set their respective data source.
11. Properties ADODC1 set their respective data fields of each control say text2(customer street ) text3 (customer city) and text1 (customer name).
12. Also add 8 command buttons and change the properties respectively.




PROGRAM:
Dim cn As Connection
Dim rs As Recordset
Private Sub add_Click()
MsgBox "enter the new record"
Adodc1.Recordset.AddNew
End Sub
Private Sub delete_Click()
Adodc1.Recordset.delete
MsgBox "records are deleted"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub exit_Click()
Unload Me
End Sub
Private Sub first_Click()
Adodc1.Recordset.MoveFirst
End Sub

Private Sub last_Click()
Adodc1.Recordset.MoveLast
End Sub
Private Sub next_Click()
If Not Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveNext
End If
End Sub
Private Sub prev_Click()
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MovePrevious
End If
End Sub
Private Sub update_Click()
Adodc1.Recordset.update
msgbox"records are updated"
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
End Sub

screen shot with their output








Related post