OleDbConnection Connect=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+p_filename+";Extended Properties=Excel 8.0;");
Connect.Open();
运行到这里就出现错误。
系统是winXP,框架1.1。错误提示是:
System.UnauthorizedAccessException: Access to the path "C:\Inetpub\wwwroot\BusAdmin\EISWEBSITE\excel\a.xls" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at EISWEBSITE.Business.Frm_ReadJL.btnSubmit_ServerClick(Object sender, EventArgs e) at System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e) at System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain() --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain() at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

解决方案 »

  1.   

    先检查路径是否正确,另外并不是所有的.xls文件都可以用ado.net读取的,只限于Excel5.0/95版本以上的工作簿
      

  2.   

    是webapp吧
    如果是的话,我想不是文件路径的问题,而是访问权限的问题,你检查aspnet用户是否能对文件存放的目录有访问权限。
      

  3.   

    如果不是权限的问题,那你检查一下以前的connection是否关闭了,一个excel文件不能同时打开两次。
      

  4.   

    就是那个connection不能打开,还不要说两次了。
    如果可以打开,我自然会通过错误处理时判断连接的状态来决定是否需要close。现在的问题是不能打开,那位有遇到这种情况的?!
      

  5.   

    dcomcnfg的配置检查过吗?以前类似的也发生过
      

  6.   

    楼主问题解决了么?
    我也碰到了这个问题,开发机上没问题,一部署到服务器上就出问题了,open出错
    有谁知道是怎么回事么?