Ado Csv Provider Help

Surjer

Registered User.
Local time
Today, 14:09
Joined
Sep 17, 2001
Messages
232
What is wrong with this...

Code:
Dim conn As New ADODB.Connection
        With conn
            .Provider = ("Driver={Microsoft Text Driver (*.txt;*.csv)};DBQ=" & fName)
            .Open()
        End With
 
I found this reference, which stated, must be entered EXACTLY for it to work:
DRIVER={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=C:\Data\MyDir;

Don't know if it will help or not
 
Cant get that to work either - I can get the jet provider to work but not this csv file provider....
 
Thanks Pat
I went a really weird route with this one lol - Used ADO.NET to get the data and then I populated a virtual recordset with the contents of the data reader..



Code:
Dim vPath As String = System.IO.Path.GetPathRoot(fName)
        Dim vFile As String = System.IO.Path.GetFileName(fName)

        Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & vPath & ";Extended Properties=""text;HDR=Yes;FMT=Delimited""")
        conn.Open()
        Dim myCommand As OleDbCommand = conn.CreateCommand()
        Dim commandString As String = "select * from " & vFile
        myCommand.CommandType = CommandType.Text
        myCommand.CommandText = commandString

        Dim dataReader As OleDbDataReader = myCommand.ExecuteReader()

        While dataReader.Read()
            rs.AddNew()
            rs(0).Value = dataReader.GetDateTime(dataReader.GetOrdinal("Date"))
            rs(1).Value = dataReader.GetDateTime(dataReader.GetOrdinal("Time"))
            rs(2).Value = dataReader.GetString(dataReader.GetOrdinal("Feature"))
            rs(3).Value = dataReader.GetString(dataReader.GetOrdinal("Crew ID"))
            rs(4).Value = dataReader.GetString(dataReader.GetOrdinal("Event"))
            rs.Update()
        End While
 
Pat, I know - Its an exported csv file poor choice of field names from the developers that created the CSV file...
 

Users who are viewing this thread

Back
Top Bottom