tags:

views:

216

answers:

1

Howdy,

I'm using an OleDbConnection, OleDbCommand, and OleDbDataReader to read a CSV file into a DataTable.

The CSV file uses the first row as a header row.

Some of the names in the header have non alphanumeric characters like ( _ . / ).

When the system creates the Column names it is transposing the . (period) character into a # (pound sign).

Why is this one character being changed and is there a way to stop the change, making the . (period) stay in the column name?

Thank you,
Keith

+1  A: 

It's replacing periods because they're metacharacters in SQL for specifying hierarchies. I don't believe it's at all advisable to try to preserve the period.

chaos
So, would you advise sourceColumnName.Replace(".", "#"); instead of trying to preserve the period?
Keith Sirmons
I'm unclear on why you would do that; isn't OLE doing it for you already?
chaos
Here is an example: object data = datatable.Rows[rowIndex][sourceColumnName.Replace(".", "#")];
Keith Sirmons