Microsoft Jet数据库引擎无法打开文件''。它已由其他用户专门打开,或者您需要获得查看其数据的权限。 [英] The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data.

查看:283
本文介绍了Microsoft Jet数据库引擎无法打开文件''。它已由其他用户专门打开,或者您需要获得查看其数据的权限。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我,我使用此代码导入文件Excel



string f = fu.PostedFile.FileName;

string fileType = f.Split('。')[1];



OleDbConnection excelCon = new OleDbConnection(Provider = Microsoft.Jet.OLEDB.4.0; Data Source =+ f +; Extended Properties = Excel 8.0);



if(excelCon.State == ConnectionState.Closed)

{

excelCon.Open();

}



OleDbCommand excelCom = new OleDbCommand(SELECT * FROM [Sheet1 $],excelCon);

OleDbDataAdapter excelAdp = new OleDbDataAdapter(excelCom);

DataSet excelDs = new DataSet();

excelAdp.Fill(excelDs);



gvSending.DataSource = excelDs.Tables [ 0];

gvSending.DataBind();



excelCon.Close();



I,m using this code for import file Excel

string f = fu.PostedFile.FileName;
string fileType = f.Split('.')[1];

OleDbConnection excelCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + f + ";Extended Properties=Excel 8.0");

if (excelCon.State == ConnectionState.Closed)
{
excelCon.Open();
}

OleDbCommand excelCom = new OleDbCommand("SELECT * FROM [Sheet1$]", excelCon);
OleDbDataAdapter excelAdp = new OleDbDataAdapter(excelCom);
DataSet excelDs = new DataSet();
excelAdp.Fill(excelDs);

gvSending.DataSource = excelDs.Tables[0];
gvSending.DataBind();

excelCon.Close();

解决方案

,excelCon);

OleDbDataAdapter excelAdp = new OleDbDataAdapter(excelCom);

DataSet excelDs = new DataSet();

excelAdp.Fill(excelDs);



gvSending.DataSource = excelDs.Tables [0];

gvSending.DataBind();



excelCon.Close();
", excelCon);
OleDbDataAdapter excelAdp = new OleDbDataAdapter(excelCom);
DataSet excelDs = new DataSet();
excelAdp.Fill(excelDs);

gvSending.DataSource = excelDs.Tables[0];
gvSending.DataBind();

excelCon.Close();


错误信息非常明确:

The error message is pretty explicit:
The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data.



这正是它所说的。文件是从不同(甚至相同)的应用程序打开的,或者文件访问权限不包括运行代码的用户的读取权限。



您需要查看打开文件的其他内容,和/或检查文件夹权限。



[edit]

其实,问题可能比这简单:你无法打开一个不存在的文件:如果文件的名称是空白的,该文件将不存在,如果你正在下载,它可能不会存在于当前的网站文件夹中它 - 检查您是否已保存在适当的文件夹中,然后在代码中使用该文件的路径。

[/ edit]


It means exactly what it says. Either the file is open from a different (or even the same) application, or the file access permissions do not include Read access for the user that runs the code.

You need to look at whatever else is opening the file, and / or check the folder permissions.

[edit]
In fact, the problem is probably simpler than that: you can't open a file that doesn't exist: and the file won't exist if it's name is blank, and probably won't exist in the current web site folder if you are downloading it - check that you have saved in in an appropriate folder as well and then use the path to that file in your code.
[/edit]


这篇关于Microsoft Jet数据库引擎无法打开文件''。它已由其他用户专门打开,或者您需要获得查看其数据的权限。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆