I am trying to delete records from my table but unable to do so. I have window form with Insert, Update, Delete and Save button. I can insert data but I can't delete specific or any records from that table. Below is my code.
Whenever I click 'delete' button I get ("Error while deleting record on table..." & ex.Message, "Delete Records") msgbox only.
Am I missing something? Please advise. Any help would be great. Thank you!
Private Sub Deletebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Deletebtn.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Server=USRAG-L-0067215\SQLEXPRESS;Database=Alamo Products_Design Data;Trusted_Connection=True"
cmd.Connection = con
cmd.CommandText = "Delete From Design_ParameterswhereDesignID=@DesignID "
cmd.Parameters.Add(New SqlParameter("@DesignID", " Am I missing any value here?"))
If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
Catch ex As Exception
MessageBox.Show("Error while deleting record on table..." & ex.Message, "Delete Records")
Edited 10-Dec-12 10:58am
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)