I'm using SQL 2014, Visual Studio 2013. I have the following code that's part of a larger script task:
//Load DataTable1 with Source Excel Sheet Data
OleDbCommand oconn = new OleDbCommand("select * from [" + sheetname + "]", cnn);
OleDbDataAdapter adp = new OleDbDataAdapter(oconn);
DataTable dt = new DataTable();
adp.Fill(dt);
What I would like to do next is select a targeted number of columns from datatable1, and fill another datatable. Something like this:
//Load another DataTable with Data from datatable1
OleDbCommand oconn2 = new OleDbCommand("select [column1], [column2] from datatable1", cnn);
OleDbDataAdapter adp2 = new OleDbDataAdapter(oconn2);
DataTable dt2 = new DataTable();
adp2.Fill(dt2);
Is this possible? The reason behind this is complicated, but I don't know another way around it. My source files are Excel. So the data needs to be brought into a datatable. Then the column names need to modified. Then a table can be made with the modified column names. But first, the data needs to be brought into a datatable as is, as I'm not sure I want to modify the source files.
Thank you.