Reputation: 52241
Update--------
I am trying to import data from excel sheet. Everything is fine, except, Column name have '.'
selectCommand.CommandText = "SELECT Date,[Meter No.] FROM [Advance EDS export$]";
This column is creating issue [Meter No.]
Upvotes: 2
Views: 2794
Reputation: 52241
Finally, I found the answer myself. When we import data from excel, if it has a . in the column name, it will automatically convert to #
For instance in my case, the original column is [Meter No.] in excel, but it converted to [Meter No#] so finally, it looks like...
selectCommand.CommandText = "SELECT Date,[Meter No#] FROM [Advance EDS export$]";
I used the select *
in command text and then check the imported datatable and found it that way.
Upvotes: 7
Reputation: 8587
You can try to escape such characters if you put all the names into square brackets...
selectCommand.CommandText = "SELECT [Date],[Meter No.] FROM [Advance EDS export$]";
similar question: msdn forum
Upvotes: 0
Reputation: 17724
You have to use a quote for such names.
selectCommand.CommandText = "SELECT Date,c1 FROM ['Advance EDS export$']";
Upvotes: 0