how to save records in listview into ms access database table using a button , i've tried with my codes but nothing is saved in the database
`Inline Code Example Here`
private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim con As New OleDbConnection
con.ConnectionString = "Provider= microsoft.jet.oledb.4.0; data source = ..\Jualan.mdb"
Dim cmd As New OleDbCommand()
InitializeComponent()
con.Open()
For i As Integer = 0 To ListView1.Items.Count - 1
Dim query As String = "INSERT INTO Jual VALUES (No_resit, Kod_produk, Nama_produk, Harga, Kuantiti, Tarikh, Sub_total)"
cmd = New OleDbCommand(query, con)
cmd.Parameters.Add("No_resit", OleDbType.[Integer]).Value = (ListView1.Items(i).SubItems(1).Text)
'!!
cmd.Parameters.Add("Kod_produk", OleDbType.VarChar, 50).Value = ListView1.Items(i).SubItems(2).Text
cmd.Parameters.Add("Nama_produk", OleDbType.VarChar, 50).Value = ListView1.Items(i).SubItems(3).Text
cmd.Parameters.Add("Harga", OleDbType.VarChar, 50).Value = ListView1.Items(i).SubItems(4).Text
cmd.Parameters.Add("Kuantiti", OleDbType.VarChar, 50).Value = ListView1.Items(i).SubItems(5).Text
'!!
cmd.Parameters.Add("Tarikh", OleDbType.VarChar, 50).Value = ListView1.Items(i).SubItems(0).Text
' !!
cmd.Parameters.Add("Sub_total", OleDbType.VarChar, 50).Value = ListView1.Items(i).SubItems(6).Text
' !!
cmd.ExecuteNonQuery()
con.Close()
Next
cmd.Dispose()
End Sub
End Class