Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

I´m trying to read a csv file. I think it is well-built and i wouldn´t like to use schema.ini to format it. I´m using the following:

 

string connection = @"Provider=Microsoft.Jet.OLEDB.4.0;" +

"Data Source=" + Path.GetDirectoryName(fileName) + ";" +

"Extended Properties='text;HDR=YES;FMT=Delimited'";

 

 

// Select statement

//string selectChargeback = "SELECT * FROM [" + excelSheet + "$]";

string selectChargeback = @"select * from [" + Path.GetFileName(fileName) + "]";

 

// Fill OleDbDataAdapter with the excel datasheet

using (OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(selectChargeback, connection))

{

oleDbDataAdapter.Fill(dataTable);

return dataTable;

}

 

Using this piece of code I get only the first column of the csv file with all its rows. Any idea why this is happening?

 

Thanks in advance.

 

Kind regards,

Adolfo.

Adolfo.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...