Check
Existing Data and Add Data in Oracle Database:
Imports System.Data
Imports
Oracle.DataAccess.Client
Imports
Oracle.DataAccess.Types
Example of VB Programming for check existing data
and Add data:
Private Sub addbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles addbtn.Click
If (TextBox1.Text
= "") Then
MsgBox("Please
Type RegNo")
ElseIf (TextBox2.Text
= "") Then
MsgBox("Please
Type Name")
Else
Dim
oradb As String
= "Data Source=XE;User Id=HR;Password=password;"
Dim
conn As New OracleConnection(oradb)
conn.Open()
Dim
cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "SELECT * FROM REG_DETAILS WHERE REGNO='"
& TextBox1.Text & "' AND NAME='"
& TextBox2.Text & "'"
cmd.CommandType = CommandType.Text
Dim
drd As OracleDataReader
drd = cmd.ExecuteReader()
If drd.Read()
Then
TextBox1.Text = drd("REGNO")
TextBox2.Text = drd("NAME")
MsgBox("Data
are Already exist")
Else
Dim
cmd1 As New OracleCommand
cmd1.Connection = conn
cmd1.CommandText = "insert into reg_details values ('"
& TextBox1.Text & "','"
& TextBox2.Text & "')"
cmd1.CommandType = CommandType.Text
cmd1.ExecuteNonQuery()
MsgBox("Record
is successfully stored")
conn.Dispose()
End
If
End If
End Sub