I am trying to save the items in a listview to Access database. The listview has two columns;
"Description and Price".
For example, If a user adds three Items (products) in a listview and clicks a command button, I want these items to be saved in a database table calleed "tblSales", each item list in listview to be inserted in a new table row.
The code I have tried so far is
Private Sub btnCpltSale_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCpltSale.Click myConnToAccess.Open() For Each Sale As ListViewItem In lsv1.Items Dim sqlQuery As String = "INSERT INTO tblSales (proDescription, SaleValue) Values ('" & _ Sale.SubItems(0).Text & "' ,'" & _ Sale.SubItems(1).Text & "')'" Dim cmd As New OleDbCommand With cmd .CommandText = sqlQuery .Connection = myConnToAccess .ExecuteNonQuery() End With MsgBox("Data Saved") lsv1.Items.Clear() Next End Sub
But When the programm is run, it is givving an error message "Missing semi colon in in the sql statement". This error is occuring at ".ExecuteNonQuery()" line.
Someone to help me please.
Thanks in advance.