I used this code delete recods from table ............
in VBP is database name
Sell-is a table name
The DELETE statement conflicted with the REFERENCE constraint "FK_Sells_Product_Details". The conflict occurred in database "VBP", table "dbo.Sells", column 'P_Id'. The statement has been terminated.
Dim check As Integer
Dim cmdproduct As New SqlCommand
Dim daStudent As New SqlDataAdapter
Dim dsStudent As New DataSet
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
cmdproduct = myConnection.CreateCommand
cmdproduct.CommandText = "DELETE FROM Product_Details WHERE P_Id ='" & Trim(ComboBox2.Text) & "'"
check = cmdproduct.ExecuteReader.RecordsAffected
If check > 0 Then
MsgBox("Student With MajorName " & Trim(TextBox1.Text) & " Succesfully To Delete", MsgBoxStyle.OkOnly, "Info Delete Student")
Else
MsgBox("Student With MajorName " & Trim(TextBox1.Text) & " Failure To Delete", MsgBoxStyle.OkOnly, "Info Delete Student")
End If
refreshComponents()
myConnection.Close()