October 18th, 2012, 05:15 AM
Reading Excel Files
I used this code:
And it worked fine. Then I started writing another app for merging xls files. It thrown exceptions on the dataset, that it couldn't find [FILE1$] (where 'FILE1' whatever the file's name).
DtSet = new System.Data.DataSet();
MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data
Source='C:\\FILE1.xls';Extended Properties=Excel 8.0;");
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [FILE1$]", MyConnection);
dataGridView1.DataSource = DtSet.Tables;
So I went back to the firts app to test it a bit. Well after a few experimentations I cant get it to work. Not even the code I quote above, that actually worked in the first place.
Needless to say that I haven't strudied all documentation about datasets and stuff yet, but I really need to get this done.
What am I missing?
Click Here to Expand Forum to Full Width