Results 1 to 4 of 4

Thread: listview all item to save access Please help:(

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    21

    Unhappy 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

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    21

    Re: listview all item to save access (with adodc) Please help:(

    help meeeeeeeeeee

  3. #3
    Hyperactive Member jp26198926's Avatar
    Join Date
    Sep 2008
    Location
    General Santos City, Philippines
    Posts
    310

    Re: listview all item to save access (with adodc) Please help:(

    tryAdodc1.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
    "More Heads are Better than One"

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    21

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width