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).Code: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); MyCommand.TableMappings.Add("Table", "TestTable"); MyCommand.Fill(DtSet); dataGridView1.DataSource = DtSet.Tables[0]; MyConnection.Close();
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?


Reply With Quote
Bookmarks