hello, i am trying to save data in my listview item to access database.. i am new to programming and i am currently working on a project i need to submit very soon, this is really urgent and i will be much happy if i could get assisted as soon as possible.. My listview has four columns Product name, Price, Quantity, Total.I want to save the data under these columns in to database with the same columns also. this is my code so far
Try
Dim i, c As String
Dim a, b, d As String
i = ListView1.Items.Count - 1
While i >= 0
a = ListView1.Items.Item(i).Text
b = ListView1.Items.Item(i).SubItems.Item(1).Text
c = ListView1.Items.Item(i).SubItems.Item(2).Text
d = ListView1.Items.Item(i).SubItems.Item(2).Text
Dim strSQL As String
Dim objCmd As New OleDbCommand
strSQL = "INSERT INTO tblSalesData(ProductName, ProductPrice, Quantity, TotalPrice) VALUES ('" + a + "','" + b + "','" + c + "','" + d + "')"
Dim Con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ShopdbData.accdb;Jet OLEDB:Database Password=salesmanager")
Con.Open()
objCmd = New OleDbCommand(strSQL, Con)
objCmd.ExecuteNonQuery()
Con.Close()
MsgBox("Transaction Successfully", MsgBoxStyle.Information, "The Shop Keeper")
End While
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try