Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading CSV file into DataSet 1

Status
Not open for further replies.

becks774

Programmer
Jun 25, 2007
14
Hello All,

I have this code that I am trying to read a CSV file into a Data Set. I have been researching this quite a bit and have tried the resolutions I have found.

If I se this code, the values that are not numeric do not get read into the dataset:
Code:
 con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + IO.Path.GetDirectoryName(strCurrent) + ";" + "Extended Properties=""Text;HDR=No;IMEX=1"""
                con.Open()
                cmd.Connection = con
                cmd.CommandText = "SELECT * FROM MPMCurrent1.csv"
                da.SelectCommand = cmd
                da.Fill(ds, "Actuals")

If I try this connection string, I get an " "Could not find installable ISAM."" error:
Code:
                  con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + IO.Path.GetDirectoryName(strCurrent) + ";" + "Extended Properties=""IMEX=1"""
                con.Open()
                cmd.Connection = con
                cmd.CommandText = "SELECT * FROM MPMCurrent1.csv"
                da.SelectCommand = cmd
                da.Fill(ds, "Actuals")

Please help.
Thank you!
 
I believe if you have only numeric values in the first 8 rows, the column will be treated as a numeric datatype. Have you tried using a schema.ini file?

Have a look here:
Hope this helps,

Alex

[small]----signature below----[/small]
Majority rule don't work in mental institutions

My Crummy Web Page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top