listview all item to save access Please help:(
Code:
Dim x As Integer
Call Adoconn 'CONNECTING TO DATABASE
Adodc1.RecordSource = "SELECT * FROM mytable Where aa= '" & ListView1.SelectedItem.SubItems(1) & "'"
Adodc1.Recordset.AddNew
x = ListView1.ListItems.Count
Adodc1.Recordset.Fields("aa") = ListView1.ListItems(x).SubItems(1)
Adodc1.Recordset.Fields("bb") = ListView1.ListItems(x).SubItems(2)
Adodc1.Recordset.Fields("cc") = ListView1.ListItems(x).SubItems(3)
Adodc1.Recordset.Fields("dd") = ListView1.ListItems(x).SubItems(4)
Adodc1.Recordset.Update
Adodc1.Recordset.MoveNext
I could not add records
please help me
thanx
Re: listview all item to save access (with adodc) Please help:(
Re: listview all item to save access (with adodc) Please help:(
try:(Adodc1.REfresh)
Code:
Dim x As Integer
Call Adoconn 'CONNECTING TO DATABASE
Adodc1.RecordSource = "SELECT * FROM mytable Where aa= '" & ListView1.SelectedItem.SubItems(1) & "'"
Adodc1.Refresh
Adodc1.Recordset.AddNew
x = ListView1.ListItems.Count
Adodc1.Recordset.Fields("aa") = ListView1.ListItems(x).SubItems(1)
Adodc1.Recordset.Fields("bb") = ListView1.ListItems(x).SubItems(2)
Adodc1.Recordset.Fields("cc") = ListView1.ListItems(x).SubItems(3)
Adodc1.Recordset.Fields("dd") = ListView1.ListItems(x).SubItems(4)
Adodc1.Recordset.Update
Adodc1.Recordset.MoveNext
Re: listview all item to save access Please help:(
Thanks for your help :))))
I've solved. Maybe that will benefit
Code:
Dim i As Long
Dim ADOCn As ADODB.Connection
Dim ConnString As String
Dim sSQL As String
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=mydatabase.mdb;" & _
"Persist Security Info=False"
Set ADOCn = New ADODB.Connection
ADOCn.ConnectionString = ConnString
ADOCn.Open ConnString
For i = 1 To ListView1.ListItems.Count
sSQL = "INSERT INTO GarantiListe(aa) "
sSQL = sSQL & "VALUES ('" & ListView1.ListItems(i).SubItems(1) & "')" 'fields continue to be
ADOCn.Execute sSQL
Next
ADOCn.Close
Set ADOCn = Nothing