In this post we have learned completely about Delete Query. How do we delete the data in the SQL server database. For this we need to take four number of text boxes and one number of buttons from the toolbox. After that one has to use the coding given below as per the instruction of the video. This coding is useful in many software. As for how to delete the data, we will use the same query for that.

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click If TextBox1.Text = "" Then MessageBox.Show("First Search Data") Else If MessageBox.Show("Are you sure to delete this entry ", "Delete Box", MessageBoxButtons.YesNo, _ MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then Dim cmded As New SqlCommand ' cmded.Connection = cnoo cnoo.Open() cmded.CommandText = ("Delete From table2 where number= @number") cmded.Parameters.Add(New SqlParameter("@number", TextBox1.Text)) cmded.ExecuteNonQuery() cnoo.Close() TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" PictureBox1.Image = Nothing MessageBox.Show("Data successfully deleted") Else MessageBox.Show("you clicked no") End If End If End Sub
 
Top