7

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.

spottedmahn
  • 14,823
  • 13
  • 108
  • 178
Freelancer
  • 9,008
  • 7
  • 42
  • 81

4 Answers4

4

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.

Diosney
  • 10,520
  • 15
  • 66
  • 111
Kirtlander
  • 91
  • 1
  • 4
  • The OP is already using SSPI, so this clearly doesn’t answer the original question. Instead, you are posing a new question and answering it. – Jeremy Caney Jul 29 '23 at 16:32
3

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

Alex
  • 8,827
  • 3
  • 42
  • 58
  • Do you have any idea how I am supposed to know the CLSID? I can't seem to find anything about this (your link is expired) – Bassie Mar 21 '20 at 00:17
  • @Bassie I did a search for "Microsoft KB 269495" and found this link which appears to be an archived version of the KB document referenced. https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/269495 – Richard Chambers Feb 24 '23 at 23:29
1

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=

zak
  • 310
  • 3
  • 19
1

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.