I am trying to save data from a listview control to Microsoft SQL Server. When I run the code no any error is showing but the data is not been saved in the database. Can someone kindly help me?
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim con As New SqlConnection(InvoiceClass.GetConnectionString()) ' My Connection String
con.Open()
For Each item As ListViewItem In Lstview.Items
Dim command As SqlCommand = New SqlCommand("SP_InvoiceSave", con)
command.Parameters.AddWithValue("@ItemName", item.SubItems(0).Text)
command.Parameters.AddWithValue("@Qty", item.SubItems(1).Text)
command.Parameters.AddWithValue("@SellingPrice", item.SubItems(2).Text)
command.CommandType = CommandType.StoredProcedure
Dim adapter As SqlDataAdapter = New SqlDataAdapter(command)
Next
MsgBox("done")
End Sub
1 Answer