Reading in CSV file

T

tshad

I am reading in a .csv file like so:

Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
If f.Exists(path & "allocation.csv") Then
Dim da2 As New OleDb.OleDbDataAdapter("Select * from " & "allocation.csv",
conn)
da2.Fill(DTDepartment)
End If

The data looks like:

TOM SMITH T,088,310,0.25
LARRY JONES T,099,310,0.75
....

2 PROBLEMS.

1) if I had the same thing, but with titles so my columns had titles, is
there a way to tell it to use the 1st row as column titles?
2) is there a way to tell it that the 2nd column is text and not numeric, so
it doesn't drop the leading zero (088 is becoming 88 in my datatable).

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top