Visual Basic Guide
Visual Basic Guide
Database connectivity
Steps
Start Programs Microsoft Visual Studio Microsoft Visual Basic File New project StandardEXE Place the required controls in the form.
Steps
Steps
Add ADO control thro Project Components
Steps
Add the ADODC control to form.
Steps
Right click on the control properties Build ADODC
Steps
Now select provider for Oracle
Steps
Enter username and password Connection OK Test
Steps
Copy the Connection String and use it while coding
Steps
Write coding for each command button
Code
Dim con As ADODB.Connection Dim rs As New ADODB.Recordset Private Sub Form_Load() Set con = New ADODB.Connection Set rs = New ADODB.Recordset con.Open ("Provider=MSDAORA.1;User ID=scott;Password=tiger;Persist Security Info=False") rs.Open "select * from dept", con, adOpenDynamic, adLockOptimistic Text1.Text = rs("deptno") Text2.Text = rs("dname") Text3.Text = rs("loc") End Sub Underlined text is the connection String copied .. Type password manually.. Now the ADODB control in form can be removed
Code
Private Sub Command3_Click() rs.MoveFirst Text1.Text = rs("deptno") Text2.Text = rs("dname") Text3.Text = rs("loc") End Sub Private Sub Command4_Click() rs.MoveLast Text1.Text = rs("deptno") Text2.Text = rs("dname") Text3.Text = rs("loc") End Sub
Code
Private Sub Command3_Click() rs.MoveFirst Text1.Text = rs("deptno") Text2.Text = rs("dname") Text3.Text = rs("loc") End Sub Private Sub Command4_Click() rs.MoveLast Text1.Text = rs("deptno") Text2.Text = rs("dname") Text3.Text = rs("loc") End Sub
Code
Private Sub Command5_Click() Set con = New ADODB.Connection Set rs = New ADODB.Recordset con.Open ("Provider=MSDAORA.1;User ID=scott;Password=tiger;Persist Security Info=False") rs.Open "insert into dept values(" & Text1.Text & ",'" & Text2.Text & "','" & Text3.Text & "')", con, adOpenDynamic, adLockBatchOptimistic con.Close MsgBox "record inserted" End Sub