Jet数据库引擎无法打开

Jet数据库引擎无法打开

本文介绍了Microsoft Jet数据库引擎无法打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我得到以下错误:



hello ,

I get Following error :

The Microsoft Jet database engine cannot open the file 'D:\AspProject\ExportToExcel\Web\UploadFiles'.  It is already opened exclusively by another user, or you need permission to view its data. 

推荐答案

string strFileType = System.IO.Path.GetExtension(filepath.ToLower());
                      string sSourceConstr = String.Empty;


                      if (strFileType.Trim() == ".xls")
                      {
                          sSourceConstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + filepath + "; Extended Properties=\"Excel 8.0; HDR=Yes; IMEX=2\"";
                      }
                      else if (strFileType.Trim() == ".xlsx")
                      {
                          sSourceConstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" + filepath + "; Extended Properties=\"Excel 12.0; HDR=Yes; IMEX=2\"";
                      }


                      string sDestConstr = ConfigurationManager.ConnectionStrings["Class"].ConnectionString;
                      OleDbConnection sSourceConnection = new OleDbConnection(sSourceConstr);
                      using (sSourceConnection)
                      {
                          sSourceConnection.Open();

                          string sql = "select * from [" + dr["SheetName"].ToString() + "]"; //"select * from











使用这个我解决我的问题谢谢你好!





using This i solve My Problem Thank U Guys!


这篇关于Microsoft Jet数据库引擎无法打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 07:26