Beruflich Dokumente
Kultur Dokumente
A tutorial by
B.BHUVANESWARAN
Lecturer / CSE
Rajalakshmi Engineering College
Thandalam, Chennai – 602 105
Visit my site
www.bhuvangates.com
Steps to Connect Visual Basic & Oracle
Control Name
7. For placing the DTPicker control, go to Project Æ Components (or) press Ctrl+T and
select the Microsoft Windows Common Controls-2.6.0 (SP3) from the Components and
click OK to place in the Toolbox.
10. Place the ADO Data Control by selection the Project Æ Components (or) by pressing
Ctrl+T.
12. From the Toolbox double click the Adodc control to place in the form.
13. Select the Adodc and right click. Then select ADODC Properties.
15. It opens the Data Link Properties dialog box. In that select the Microsoft OLE DB
Provider for Oracle and click Next.
17. If it displays the “Test Connection Succeeded” message, then click OK.
18. Copy the text available in the Use Connection String text box.
20. Double click the form, it loads the Form Æ Load event and enter the following code.
Private Sub Form_Load()
Set connEmp = New ADODB.Connection
connEmp.Open "Provider=MSDAORA.1;Password=baba;User ID=baba;Data
Source=IBMREC;Persist Security Info=True"
connEmp.CursorLocation = adUseClient
MsgBox "Connection Established..."
cmdClear_Click
End Sub
22. Run the program by clicking the Start button (or) by pressing F5 button. The program
will display the following message box.
23. Double click the Clear button and enter the following code.
Private Sub cmdClear_Click()
txtEmpCode.Text = ""
txtEname.Text = ""
optMale.Value = False
optFemale.Value = False
cboDesig.Text = ""
cboDept.Text = ""
txtSalary.Text = ""
End Sub
25. Double click the View button and enter the following code.
Private Sub cmdView_Click()
Set rsEmp = New ADODB.Recordset
rsEmp.Open "select * from employee where empcode = '" &
txtEmpCode.Text & "'", connEmp, adOpenKeyset, adLockReadOnly,
adCmdText
If rsEmp.RecordCount <> 0 Then
txtEname.Text = Trim(rsEmp!Ename)
If Trim(rsEmp!Gender) = "Male" Then
optMale.Value = True
ElseIf Trim(rsEmp!Gender) = "Female" Then
optFemale.Value = True
End If
dtpDob.Value = rsEmp!Dob
cboDesig.Text = Trim(rsEmp!Desig)
cboDept.Text = Trim(rsEmp!Dept)
txtSalary.Text = Val(rsEmp!Salary)
MsgBox "Viewed Succesfully..."
Else
MsgBox "Employee Code Not Exists..."
End If
rsEmp.Close
Set rsEmp = Nothing
End Sub
27. Double click the Edit button and enter the following code.
29. Click the Add button, the program displays the following Message box.
30. To see whether the values are added in the database or not, view the rows by entering the
SQL, and type select * from employee ;, the SQL displays the added record values.
32. If you want to change any value, edit it and click Edit button, then it will display the
following confirmation Message box.
33. Click Yes to change and No to remain previous values. If the selection is Yes, it displays
the following Message box.
34. To delete any record, clear the values by clicking the clear button and enter the Employee
Code in the text box and click View. If the record is available in the database it will display
the following message box.
35. If you want to delete click Delete button, then it will display the following confirmation
Message box.
40. To create an Executable file for this Project, select File Æ Make prjEmployee.exe.
41. Select the path to store the Executable file and click OK.