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

喜夏-厌秋 提交于 2019-11-26 22:02:49

问题


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:

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

Connection String is:

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

I am using oledb connections.


回答1:


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:

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

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




回答2:


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=True to Integrated Security=SSPI in the connection string fixed the problem.




回答3:


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=




回答4:


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.



来源:https://stackoverflow.com/questions/15129744/multiple-step-ole-db-operation-generated-errors-check-each-ole-db-status-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!