I'm developing a C # application that consumes data from a spreadsheet, and at some point I need a query string that will feed a variable.
For example:
strComando1 = "SELECT TOP 2 ColunaGenerica1, ColunaGenerica2 FROM ["+ planilha +"]";
I wanted to know if it is possible and how can I do to consume data from the first two columns, for example, without specifying their names, since the column names may vary according to the user import. >
Provider and connection:
private static OleDbConnection conexao = new OleDbConnection();
strConexao = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=0\"", caminhoArquivo);
conexao.ConnectionString = strConexao;
private static DataTable tabelaDeSaida;