Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Import csv file into Access 2000 table with VB6 using DAO


Message #1 by "Alister Neave" <ahneave@b...> on Wed, 23 Oct 2002 06:24:29
Thanks for such detail Toby.
Quagmired? Sounds like you're having fun!
I now remember that only certain types of records are imported.
With your method I guess you would delete the unwanted ones from the 
target table after the import.
The code I ended up with (without declarations etc) is...

    '; Open the table as a recordset
    Set rs = myDB.OpenRecordset(psTable, dbOpenTable)

    Do While fsoStream.AtEndOfStream <> True
        sRecord = fsoStream.ReadLine     '; Read the next line
        aRecArray = Split(sRecord, "|")     '; Create an array from it

        '; Only "I" (for Insert) records contain data for insertion
        If aRecArray(0) = "I" Then
            rs.AddNew
            For i = 0 To rs.Fields.Count - 1  
                rs(i) = aRecArray(i)
            Next i
            rs.Update
        End If
    Loop

Cheers
Alister

  Return to Index