c# - Putting data in dataset into datatable? -
here snippet of code:
string filepath = @"c:\drmf.xls"; filestream stream = file.open(filepath, filemode.open, fileaccess.read); iexceldatareader excelreader = excelreaderfactory.createbinaryreader(stream); excelreader.isfirstrowascolumnnames = true; dataset results = new dataset(); datatable testsheet = new datatable(); testsheet = results.tables.add("test"); results = excelreader.asdataset();
i had assumed once added datatable "test" dataset, data loaded dataset automatically load datatable "test". doesn't appear case. loading, instead, datatable called "sheet1" assume getting excel spreadsheet.
so, question is, once have data in dataset, how can "test" datatable?
try this:
dataset results = new dataset(); results = excelreader.asdataset(); results.tables["sheet1"].tablename = "test";
this way, have data loaded , can change table name whatever want , not have create tables.
Comments
Post a Comment