GridView to Excel then Excel to database table.

M

mohaaron

Has anyone else tried to save a GridView as a excel file and then use
ado.net to read the excel sheet back into a database table?

I'm having a terrible time trying to make this work. The normal method
of doing this using OleDb and a connection string like the following
doesn't work on a Excel file that has been created from a GridView.

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + file + "; Extended
Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";

When doing this ado.net throws the following error.

"External table is not in the expected format."

I did a little research and found that the Excel sheet is in the
format of a html table which this connection string won't work with. I
then found another post where someone was using "Extended
Properties=HTML Import" but when I use this I get a different error.

"The Microsoft Jet database engine could not find the object
'Sheet1$'. Make sure the object exists and that you spell its name
and the path name correctly."

So I'm now stuck and can't make this work. Any idea's would be greatly
appreciated.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top