Oracle and VB 6.0 Connectivity (Part 3)

Now we will see how to insert values into table a table and to view them.

Oracle
Initially we had created table in part1.

Visual Basic 6.0
Now we wil insert data into the table through visual basic.

The code for inserting will be as follows

When you double click on add button it will open your code window it will have this code!

Private Sub Command1_Click()
Dim gen As String
If (Option1.Value = True) Then
gen = “male”
ElseIf (Option2.Value = True) Then
gen = “female”
End If
rsv.Open “insert into voter values(” & Text5.Text & “,’” & Text2.Text & “’,’” & Text3.Text & “’,’” & Combo1.Text & “’,’” & gen & “’,’” & DTPicker1.Value & “’)”, conv, adOpenDynamic, adLockOptimistic
If (rsv.State = 1) Then
rsv.Close
End If
MsgBox (“Data Entered”)
End Sub

This will add the data entered into the fields into the oracle database.

Next is to view this entered data from table.

Visual basic code
Private Sub Command7_Click()
Dim viewv As Integer
viewv = InputBox(“enter the voter id”)

rsv.Open “select id,name,address,age,gender,dob from voter where id=’ ” & viewv & ” ‘”, conv, adOpenDynamic, adLockOptimistic

Text5.Text = rsv.Fields(“id”)
Text2.Text = rsv.Fields(“name”)
Text3.Text = rsv.Fields(“address”)
Combo1.Text = rsv.Fields(“age”)

If (rsv.Fields(“gender”) = “male”) Then
Option1.Value = True
ElseIf (rsv.Fields(“gender”) = “female”) Then
Option2.Value = True
End If

DTPicker1.Value = rsv.Fields(“dob”)

If (rsv.State = 1) Then
rsv.Close
End If
MsgBox “view”
End Sub

You are done! In the next part you will see procedures! in part 4.
Part 4

Advertisements

One thought on “Oracle and VB 6.0 Connectivity (Part 3)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s