Results 1 to 4 of 4

Thread: Text File And ADO

  1. #1
    Guest

    Angry

    I have a CSV file called "olb.txt" with 5 fields. I created a User ODBC source called "TEST" with the fields defined as:

    StartDate
    StartTime
    AppName
    Agent
    Duration

    While I've successfully used ADO to connect to an Access database, I can't get ADO to connect to this ODBC file and keep getting the error message that the driver is unrecognized.

    Can someone tell me how to setup the connection string?

    Thanks.

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Ca you use the Jet "transferSpreadsheet" function to copy the table into Access and manipulate it from there?

  3. #3
    New Member
    Join Date
    Apr 2000
    Posts
    10
    If is of any help, check the preferences.

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Here is how you can connect to a CSV file without using ODBC or Automation:

    Code:
    'Uses ADO 2.1/5
    
        Dim cn As ADODB.Connection
        Dim rs As Recordset
        
        Set cn = New Connection
        Set rs = New Recordset
        
        'open connection to folder that contains the CSV file
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=Text;"
        
        'open the file
        rs.Open "select * from test.csv", cn
        
        'we have data
        MsgBox rs.Fields(1).Value

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