I am trying to merge two excel files in asp.net and display them in gridview as one table. The code below is displaying only one table. Can anyone tell me what is the problem with the code below? If you have a better idea please let me know.
protected void MergTables()
{
string connString = ConfigurationManager.ConnectionStrings[hwTypes].ConnectionString;
OleDbConnection DBConnection = new OleDbConnection(connString);
DBConnection.Open();
OleDbCommand DBCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", DBConnection);
OleDbDataAdapter da = new OleDbDataAdapter(DBCommand);
DataSet ds = new DataSet("Stock");
da.Fill(ds, "HWTypes");
DBConnection.Close();
string _stockConn = ConfigurationManager.ConnectionStrings[stockConn].ConnectionString;
DBConnection = new OleDbConnection(_stockConn);
DBConnection.Open();
DBCommand = new OleDbCommand("SELECT * FROM [Stock_voorlopig$]", DBConnection);
da = new OleDbDataAdapter(DBCommand);
da.Fill(ds, "Stock");
DBConnection.Close();
for (int i = 0; i < ds.Tables["HWTypes"].Rows.Count; i++)
{
ds.Tables["HWTypes"].Rows[i]["ProductID"] = ds.Tables["Stock"].Rows[i]["Partno"];
}
GridView1.DataSource = ds.Tables["Stock"];
GridView1.DataBind();
}