I want to delete an item from list view and at the same I want delete the item from the Releavant table
when I click the okay button in the ** search form** i want to delete the item from listview and as well as to update it to Sell table
listview is in the** form7**
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Productid As String = ComboBox2.TextmyCommand = New SqlCommand(" DELETE FROM [Sells] WHERE P_Id = ' " & ComboBox2.Text & "' AND Bill_No='" & Val(TextBox1.Text) & "'", myConnection) myCommand.ExecuteNonQuery() MsgBox("Update successfully") listview() Me.Hide() End Sub Public Sub listview() Try Try If Form7.ListView1.Items.Count = 0 Then MsgBox("No Data to Delete", MsgBoxStyle.Information) Exit Sub End If Dim intindex As Integer For Each lstdata As ListViewItem In Form7.ListView1.SelectedItems intindex = lstdata.Index Next Form7.ListView1.Items.RemoveAt(intindex) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Catch err As Exception MsgBox(err.Message, MsgBoxStyle.Exclamation) End Try Catch err As Exception MsgBox(err.Message, MsgBoxStyle.Exclamation) End Try ''''''' myConnection.Close() End Sub
in here the data won't neither delete from listview nor from table though i get the message No Data to Delete and Update successfully
this the coding in the remove item in the form7
Dim intResponse As Integer
intResponse = MsgBox("Please Select the Product Id", MsgBoxStyle.OkCancel)
If intResponse = vbOK Then
varibles.billno = Val(TextBox14.Text)
Search.Show()
' code to end the app, such as "Me.Close" would go here
End If
End Sub
daliy sales -form7
search from- form