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
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
how perform authentication???????
ReplyDeletefor login and logout?
ReplyDeleteHow To manage when multiple rows get selected from the Query??
ReplyDeletehow to display whole database
ReplyDeletehw to exract frm database to datagrid
ReplyDeletei connected database but when i insert it tells "system.mine trigger is not valid and failed re validation"
ReplyDeletefor this error what is a solution..
i did alll steps as tell above...
any one can help me out...????
Private Sub insert_Click()
ReplyDeleteSet con = New ADODB.Connection
Set rec = New ADODB.Recordset
With con
.CursorLocation = adUseClient
.ConnectionString = "Provider=MSDASQL.1;Password=tiger;Persist Security Info=True;User ID=system;Data Source=tiger;Initial Catalog=tiger"
.Open
End With
rec.Open "tiger", con, adOpenDynamic, adLockBatchOptimistic, adCmdTable
Dim gen As String
rec.Open "insert into tiger values (' " & Text1.Text & " ' ," & Text2.Text & " ," & Text3.Text & ")", con, adOpenDynamic, adLockOptimistic
If (rec.State = 1) Then
rec.Close
End If
MsgBox ("data entered")
this is my coding for my insert button..
i got error that "operation is not allowed when object is open"
help me out...