Reputation: 151
for the query:
OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from[" + sheetName + "$] where [BARKOD] is not null", Connection);
can I get the data of specific columns for example column 1(header=ID) and 3(header=NAME) instead of whole table(*)?
Upvotes: 0
Views: 1407
Reputation: 460028
You could select the column name first, for example:
DataTable schemaColTable = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, null);
String firstColumnName = schemaColTable.Select(null, "TABLE_NAME,ORDINAL_POSITION", DataViewRowState.CurrentRows)[0]["COLUMN_NAME"].ToString();
Then you use these column names for your queries.
Upvotes: 1