Rollcredit
Rollcredit

Reputation: 453

Using OleDBDataReader to read Excel not retrieving all of a header column cells content

I have an Excel sheet that I am using to populate data in a Database. It seems as though there is only a certain number of characters that the OleDBDataReader actually reads in from a column heading before truncating the rest.

Is there a way around this?

How I am retrieving the column headings:

OleDbCommand oleDbCommand = new OleDbCommand("select * from [sheet1$]",
OleDbConnection);
OleDbDataReader reader = oleDbCommand.ExecuteReader();
DataTable dataTable = new DataTable();
dataTable.Load(reader);

foreach (DataColumn column in dataTable.Columns)
{
string columnName = column.ColumnName;
}

Expected result: Targeted programs to address the welfare needs of students. E.g breakfast clubs

Actual Result: Targeted programs to address the welfare needs of students. E.g br

I have also tried using the reader.GetName(i) method to retrieve the information with the same result.

Upvotes: 0

Views: 4289

Answers (1)

dbugger
dbugger

Reputation: 16399

64 characters is the column header limit of the Jet Engine reader.

http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/2fb51d81-3d64-445f-806a-519861b561ba/

Sorry I cannot find a better reference.

Upvotes: 1

Related Questions