VK LABELS

Monday, 30 December 2013

Add Data in Oracle Database Table

 Add Data in Oracle Database Table:

Imports System.Data
Imports Oracle.DataAccess.Client 
Imports Oracle.DataAccess.Types

Example of VB Programming  for Add Data in Oracle Database Table:

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 If
End Sub

No comments:

Post a Comment