C# 多步 OLE DB 操作产生错误。检查每个 OLE DB 状态值(如果可用)。没有完成任何工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15129744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 14:09:51  来源:igfitidea点击:

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done

c#.netoledb

提问by Freelancer

I am running following code

我正在运行以下代码

/*Fetchinch Last CustID from custMaster*/
int ID = 0;
try
{
     con.Open();
     da = new OleDbDataAdapter("select max(Id) from custMaster",con);
     DataSet ds = new DataSet();
     da.Fill(ds);
     for(int i=0;i<ds.Tables[0].Rows.Count;i++)
        ID=int.Parse(ds.Tables[0].Rows[i][0].ToString());
     con.Close();
}
catch (Exception ex) {}
finally 
{
     con.Close();
}

I am putting debugger from the first statement of try block and finding that error is coming when I am trying to open the connection. Error Text:

我将调试器从 try 块的第一个语句中放入,并在我尝试打开连接时发现错误即将到来。错误文本:

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

多步 OLE DB 操作产生错误。检查每个 OLE DB 状态值(如果可用)。没有完成任何工作。

Connection String is:

连接字符串是:

"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=E:\NewSoft\Database\TestApp.accdb;Integrated Security=SSPI"

"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=E:\NewSoft\Database\TestApp.accdb;Integrated Security=SSPI"

I am using oledb connections.

我正在使用 oledb 连接。

采纳答案by Alex

This can be the result of the error in your connection string. You should try to add

这可能是连接字符串中的错误的结果。你应该尝试添加

Persist Security Info=True;

Or you might have problems in your registry with your OLE DB provider, which must have OLEDB_SERVICES record. In the registry under HKEY_CLASSES_ROOT\CLSID, find the CLSID of the OLE DB provider and add the following registry value:

或者,您的 OLE DB 提供程序的注册表可能有问题,该提供程序必须具有 OLEDB_SERVICES 记录。在 HKEY_CLASSES_ROOT\CLSID 下的注册表中,找到 OLE DB 提供程序的 CLSID 并添加以下注册表值:

Value Name: OLEDB_SERVICES
Data Type: REG_DWORD
Value: 0xFFFFFFFF

See http://support.microsoft.com/kb/269495for more information

有关详细信息,请参阅http://support.microsoft.com/kb/269495

回答by Kirtlander

I had a similar issue when opening a connection with the following connection string:

在使用以下连接字符串打开连接时,我遇到了类似的问题:

Data Source=.\SQLEXPRESS;Initial Catalog=master;Integrated Security=True

Changing Integrated Security=Trueto Integrated Security=SSPIin the connection string fixed the problem.

在连接字符串中更改Integrated Security=TrueIntegrated Security=SSPI解决了该问题。

回答by zak

For a similar problem connecting to a MS Access database, this exact error was generated for a wrong password set in the connection attribute of Jet OLEDB:Database Password=

对于连接到 MS Access 数据库的类似问题,Jet OLEDB:Database Password=的连接属性中设置的错误密码会生成此确切错误

回答by Harpreet Singh

I was having same problem but found out to be special characters used in the password.

我遇到了同样的问题,但发现密码中使用了特殊字符。

So, I changed the Access file password and replaced Jet OLEDB:Database Password=with the updated one and it solved the issue.

因此,我更改了访问文件密码并将Jet OLEDB:Database Password=替换为更新后的密码,并解决了该问题。