I used the below code to return the datas from one excel file. My question is if i suppose need to get the records from morethan one excel file using joins, how it is possible.
string connString = ConfigurationManager.ConnectionStrings["xls"].ConnectionString;
// Create the connection object
OleDbConnection oledbConn = new OleDbConnection(connString);
// Open connection
oledbConn.Open();
// Create OleDbCommand object and select data from worksheet Sheet1
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
// Create new OleDbDataAdapter
OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.SelectCommand = cmd;
// Create a DataSet which will hold the data extracted from the worksheet.
DataSet ds = new DataSet();
// Fill the DataSet from the data extracted from the worksheet.
oleda.Fill(ds, "Employees");
So that shoule we need to use two connectionstring,adapter in single method. Is that rught way.Please i dont understand the way, could you please clarify me, if posiible by an example.
Here we are using different colummn names from different excel file. Say exmple first excel file has, ID, Name column and second excel file has ID, Desc columns. So how it is possible with merge functionality.
Member
45 Points
323 Posts
Returning datas from two excel file
Aug 17, 2010 05:45 AM|John Federer|LINK
Hi,
I used the below code to return the datas from one excel file. My question is if i suppose need to get the records from morethan one excel file using joins, how it is possible.
-ThHanks
All-Star
43204 Points
10243 Posts
MVP
Re: Returning datas from two excel file
Aug 17, 2010 06:07 AM|DarrellNorton|LINK
Just select from two different excel files, and then merge the 2 datatables:
http://msdn.microsoft.com/en-us/library/system.data.datatable.merge.aspx
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
Member
45 Points
323 Posts
Re: Returning datas from two excel file
Aug 17, 2010 06:20 AM|John Federer|LINK
Hi,
So that shoule we need to use two connectionstring,adapter in single method. Is that rught way.Please i dont understand the way, could you please clarify me, if posiible by an example.
-Thanks
Member
45 Points
323 Posts
Re: Returning datas from two excel file
Aug 17, 2010 06:35 AM|John Federer|LINK
Here we are using different colummn names from different excel file. Say exmple first excel file has, ID, Name column and second excel file has ID, Desc columns. So how it is possible with merge functionality.
-Thanks
Member
45 Points
323 Posts
Re: Returning datas from two excel file
Aug 18, 2010 08:44 AM|John Federer|LINK
Hi,
Any suggetions are welcome
-Thanks