Add Data in Oracle Database Table:
Imports System.Data
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Private Sub addbtn_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles addbtn.Click
If (Name.Text = "") Then
MsgBox("Please
Type Name")
ElseIf
(Regno.Text = "") Then
MsgBox("Please
Type Register No")
ElseIf
(mark1.Text = "") Then
MsgBox("Please
Type Mark1")
ElseIf
(mark2.Text = "") Then
MsgBox("Please
Type Mark2")
ElseIf
(mark3.Text = "") Then
MsgBox("Please
Type Mark3")
ElseIf
(mark4.Text = "") Then
MsgBox("Please
Type Mark4")
ElseIf
(mark5.Text = "") Then
MsgBox("Please
Type Mark5")
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 = "insert into table_name values ('" &
Name.Text & "','" & Regno.Text
& "','" & mark1.Text &
"','" & mark2.Text & "','" & mark3.Text & "','" & mark4.Text & "','" & mark5.Text & "')"
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
MsgBox("Record
is successfully stored")
conn.Dispose()
End IfEnd Sub
No comments:
Post a Comment