我正在尝试将列表视图控件中的数据保存到 Microsoft SQL Server。当我运行代码时,没有显示任何错误,但数据没有保存在数据库中。有人可以帮助我吗?
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