直接調式可以(不管在自己機器上還是在服務器上調式都行),發布到服務器上后出錯...
錯誤提示如下:
The Microsoft Jet database engine could not find the object 'Sheet2$'. Make sure the object exists and that you spell its name and the path name correctly.
描述: 在執行目前 Web 要求的過程中發生未處理的例外情形。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。 例外詳細資訊: System.Data.OleDb.OleDbException: The Microsoft Jet database engine could not find the object 'Sheet2$'. Make sure the object exists and that you spell its name and the path name correctly.
既然找到不Sheet2$,那為什么同樣的Excel直接調試就可以,發布后就出錯呢?
錯誤提示如下:
The Microsoft Jet database engine could not find the object 'Sheet2$'. Make sure the object exists and that you spell its name and the path name correctly.
描述: 在執行目前 Web 要求的過程中發生未處理的例外情形。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。 例外詳細資訊: System.Data.OleDb.OleDbException: The Microsoft Jet database engine could not find the object 'Sheet2$'. Make sure the object exists and that you spell its name and the path name correctly.
既然找到不Sheet2$,那為什么同樣的Excel直接調試就可以,發布后就出錯呢?
解决方案 »
- 使用了lhgdialog.opendlg弹出一个页面,怎么关闭它
- 关于音乐地址的问题。。。知道或者不知道的都来讨论下
- 为什么连个面试机会都没有
- 数据太大直接帮定划不来 请问怎么解决 给个思路
- 我的一个关于代替Session的想法请大家积极讨论!
- 出现连接到我的计算机的登陆框
- 光盘加密的问题
- 为什么用datagrid1.DataKeys[datagrid1.SelectedIndex]取的ID只有一个;
- .NET2002捆绑的水晶报表默认5个并发用户具体什么含义?请思归等高手帮忙,急。。。
- 如何取一个字符串的前几位,和中间几位?
- 彈出模態窗口前,不彈出提示
- VS2005 GridView的使用(删除,修改等功能的提示选项)
if (FileUpload1.PostedFile.ContentLength > 0)
{
string dataSource = FileUpload1.PostedFile.FileName;
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + dataSource + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Sheet2$]", strConn);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet);
DataTable dt = myDataSet.Tables[0];
//这里的FileName还是client端的文件名吧?
//试试FileUpload1.PostedFile.SaveAs到IIS上的某个目录下再开启connection.string dataSource = FileUpload1.PostedFile.FileName;