VK LABELS

Saturday, 15 March 2014

Remove Data from Database Table

Remove Data from Database Table:

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

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If (TextBox1.Text = "") Then
            MsgBox("Please Type RegNo")
       ElseIf (TextBox2.Text = "") Then
            MsgBox("Please Type Name")
       Else
            Using conn = root.Opencon()
                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")
                    If Dialog3.ShowDialog() = Windows.Forms.DialogResult.OK Then
                        Dim cmd1 As New OracleCommand
                        cmd1.Connection = conn
                        cmd1.CommandText = "delete from reg_details where REGNO='" & TextBox1.Text & "' AND NAME='" & TextBox2.Text & "'"
                        cmd1.CommandType = CommandType.Text
                        cmd1.ExecuteNonQuery()
                        MsgBox("Record is successfully deleted")
                    ElseIf Dialog3.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
                        Dialog3.Close()
                    End If
                Else
                    MsgBox("Please Type Correct Data to Delete")
                End If
            End Using
         End If
    End Sub


No comments:

Post a Comment