rxbanditboy1112 Posted December 14, 2007 Share Posted December 14, 2007 Hi I recieve the following message at the line dr.Excel.Fill(dataSet1); dataSet1 is a dataSet object created in form1. "The Microsoft Jet database engine could not find the object 'orders'. Make sure the object exists and that you spell its name and the path name correctly." Here is the source (assume windows open dialog works): if(openFileDialog1.ShowDialog() == DialogResult.OK) { m_fileLocation = openFileDialog1.FileName; } string theConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_fileLocation + ";Extended Properties='HTML Import;HDR=YES;IMEX=1;'"; // // Open the spreadsheet and query the data. // OleDbConnection cnExcel = new OleDbConnection(theConnectionString); try { cnExcel.Open(); } catch (OleDbException eee) { // catch (OleDbException eee) MessageBox.Show(eee.Message); } OleDbCommand cmdExcel = new OleDbCommand(); cmdExcel.Connection = cnExcel; cmdExcel.CommandText = @"SELECT * FROM [orders]"; OleDbDataAdapter drExcel = new OleDbDataAdapter(); drExcel.SelectCommand = cmdExcel; drExcel.Fill(dataSet1); cnExcel.Close(); Anyone see what i am doing wrong? I think the problem occur is at : cmdExcel.CommandText = @"SELECT * FROM [orders]"; I have also tried cmdExcel.CommandText = @"SELECT * FROM [orders$]"; THANKS FOR THE HELP!!! Quote Link to comment https://forums.phpfreaks.com/topic/81643-c-reading-excel-from-an-excel-file/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.