查询:
OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from[" + sheetName + "$] where [BARKOD] is not null", Connection);
我可以获取特定列的数据,例如第1列(header = ID)和3(header = NAME)而不是整个表(*)?
答案 0 :(得分:1)
您可以先选择列名称,例如:
DataTable schemaColTable = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, null);
String firstColumnName = schemaColTable.Select(null, "TABLE_NAME,ORDINAL_POSITION", DataViewRowState.CurrentRows)[0]["COLUMN_NAME"].ToString();
然后您将这些列名称用于查询。