Raja

Raja

  • NA
  • 2k
  • 358.6k

How to merge the datatable in dataset? Asp.net C#

Aug 16 2016 12:31 AM
i have one excel document and multiple sheets.sheets have many columns and row.i upload the document into my project.and the multiple sheets is bind to tables(sheet name is set as table name) using for loop.after the bind i change the table name to table1,table2,table3(three sheets). Now how to bind(merge) the three tables in single table (table1).
I have Tried:
i have tried to rename the all tables to same name but the duplicate table is not allowed.how to bind the same table.
 
I have used below code to convert Excelsheet to Dataset and named table as table1,table2,table3. and generate xml xml tags have combined all three tables.i have add column in table and start tag and tag as <table1></table1>... <table n></table n> now the starting and ending tag must be same.then only back end sql is get the value so how to merge the table.i try this code if any other method is available pls suggest me.sorry for the late reply and same question ask again and again. 
 
 for (int k = 0; k < ds.Tables.Count; k++)
{
int c = k + 1;
string sheetname = ds.Tables[k].ToString();
if (ds.Tables[k].ToString() == "ExcelSheetName" + c)
{
ds.DataSetName = "Search"; ds.Tables[k].TableName = "Table" + c; ds.Tables["Table" + c].AcceptChanges();
}
}

Answers (1)