CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2002
    Location
    India
    Posts
    103

    HDR=No doesnt work

    Hi Guru's

    I have a little problem while reading the data from a CSV file. I use the
    ODBCAdapter.Fill() method to populate data in a data table. But some how the connection does not recognize the HDR=No parameter.
    The first row in the CSV file is data and not the Column Headers.. But still the first row is treated as Column Header. Can any one help in this... its very urgent...
    Below is the code...
    Code:
    Try
                strConn = "DefaultDir=" & sDir & ";Driver={Microsoft Text Driver (*.txt; *.csv)};Extended Properties='text;HDR=No;'"
                Dim strSelect As String
                Dim conn As Odbc.OdbcConnection
                conn = New Odbc.OdbcConnection(strConn)
                conn.Open()
                strSelect = "Select * from " & textFile
                odbcAdpater = New Odbc.OdbcDataAdapter(strSelect, conn)
                odbcAdpater.Fill(dt)
                conn.Close()
                Return dt
            Catch ex As Exception
                myErrCol.Add(ex.Message)
            End Try
    Nilesh
    Pune, Maharashtra
    India

  2. #2
    Join Date
    Jan 2006
    Posts
    293

    Re: HDR=No doesnt work

    You can try the Jet Provider with an OleDB connection...
    Code:
    Dim ConnProvider As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=""text;HDR=No;FMT=Delimited"""
    I also wrote a homebrew function that just uses regular string manipulation in order to create a datatable of the data in the CSV file, you can find it here

  3. #3
    Join Date
    Oct 2002
    Location
    India
    Posts
    103

    Re: HDR=No doesnt work

    Hi,

    I tried to use OLEDB and to some extent it is working.
    Problem is that the OLEDB connection adds the file name to some columns and other columns still have the data in the heading. I dont know why it is doing so.. can u tell me what may going wrong??
    Nilesh
    Pune, Maharashtra
    India

  4. #4
    Join Date
    Jan 2006
    Posts
    293

  5. #5
    Join Date
    Jul 2012
    Location
    Ohio
    Posts
    13

    Re: HDR=No doesnt work

    Are you using a schema.ini? I just had the same issue and found in schema.ini there is a setting called ColNameHeader=FALSE and BTW even though this is 6 years old I joined just to post this. So sorry for bringing a forum back from the dead but I felt obligated to answer this post.

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

Featured