I would like to ask if it is possible to retrieve a row of data from a INNER JOIN query from TWO different Excel files (example. excel1.xls, excel2.xls).
I am using C# .net. and an OledbConnection
.
Excel1.xls Column 1 BookID 1234 1515 2315
Excel2.xls Column 1 BookID 1234 1515 1100 1412 2215
Goal: I must retrieve only those rows in Excel1.xls that are included in Excel2.xls
Here's my code for the function: txtshowstopperpath.text = path of the Excel1.xls txtexcelpath.text = Path of the Excel2.xls
sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={1};Extended Properties=Excel 12.0;";
oConn = new OleDbConnection(sConnString);
oConn.Open();
sCommand = "SELECT * FROM [" + txtshowstopperpath.Text + "].[Sheet1$] A INNER JOIN [" + txtexcelpath.Text + "].[Sheet1$] B on A.[Book ID] = B.[Book ID]";
oComm = new OleDbCommand(sCommand, oConn);
oRdr = oComm.ExecuteReader();
oTbl = new DataTable();
oTbl.Load(oRdr);
foreach (DataRow row in oTbl.Rows)
{
dgridshowrep.DataSource = oTbl;
}
oConn.Close()
Thank you.