I am using the following code to delete record it did not delete record but just only populate message record deleted successfully what should i do now please please help me.

If TextBox1.Text = "" Then
            MessageBox.Show("Please Select record to delete......", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End If
        If MessageBox.Show("Do you really want to Delete this Record?", _
                "ALI ENTERPRISES", MessageBoxButtons.YesNo, _
                MessageBoxIcon.Warning) = DialogResult.Yes Then
            MessageBox.Show("Record Deleted Successfully......", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
            TextBox5.Text = ""
        Else
            Exit Sub
        End If
        Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        Try
            con.ConnectionString = "Data Source=ITS;Initial Catalog=Payment;Integrated Security=True"
            con.Open()
            cmd.Connection = con

            cmd.CommandText = "DELETE FROM CustomerInformation WHERE CustomerID ='" & Trim(TextBox4.Text) & "'"
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show("Error while Deleting record From table..." & ex.Message, "Delete Records")
        Finally
            If con.State = ConnectionState.Open Then

                con.Close()

            End If
        End Try

One thing, if CustomerID is an INT value in your table you need to remove the single quotes from around it in your delete statement, like this

cmd.CommandText = "DELETE FROM CustomerInformation WHERE CustomerID =" & Trim(TextBox4.Text)

Also, this code is primed for a SQL Injection attack, you really should be using parametrized queries for this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.