-
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
-
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
-
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??
-
Re: HDR=No doesnt work
Can you post some of the test code you are using to connect and fill the datagrid?
-
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.