This project has moved. For the latest updates, please go here.

Can anybody help me with JetAttachDatabase function error?

Oct 7, 2011 at 5:09 PM

Can anybody help me with JetAttachDatabase function error code?

http://stackoverflow.com/questions/7690225/how-to-attach-edb-database-using-extensible-storage-engine-api

I was trying to attach to Exchange Server database file using Managed Esent API but I got the next error: "Checksum error on a database page" or JET_errReadVerifyFailure on calling JetAttachDatabase. Can anybody explain what does it mean and how to fix it? This database was attached successfully from C++ application using the same API.

Code:

int pageSize;
Api.JetGetDatabaseFileInfo(fileName, out pageSize, JET_DbInfo.PageSize);

SystemParameters.DatabasePageSize = pageSize;

JET_INSTANCE jetInstance;
string jetInstanceName = Guid.NewGuid().ToString("N");
Api.JetCreateInstance(out jetInstance, jetInstanceName);

try
{
  SetSystemParameters(jetInstance, fileName, jetInstanceName);

  Api.JetInit(ref jetInstance);

  JET_SESID jetSessionId;
  Api.JetBeginSession(jetInstance, out jetSessionId, "admin", "password");

  try
  {
    Api.JetAttachDatabase(jetSessionId, fileName, AttachDatabaseGrbit.ReadOnly);
  }
  finally
  {
    Api.JetEndSession(jetSessionId, EndSessionGrbit.None);
  }
}
finally
{
  Api.JetTerm(jetInstance);
}

In SetSystemParameters method I set only SystemPath and TempPath parameters. May be I need to set any additional parameters to fix my problem?

Thanks.

Developer
Oct 25, 2011 at 7:57 PM

Usually a checksum error is indicative of a hardware problem.

But as was mentioned in the stackoverflow page, you can't use an older database engine to open up a file created with a newer engine. In this case the checksum algorithm changed from version to version, in which case the older version couldn't understand the new format.

And we also don't support opening an Exchange database with the Windows esent.dll.

-martin

Oct 26, 2011 at 8:34 AM
Edited Oct 26, 2011 at 8:35 AM
martinc wrote:

And we also don't support opening an Exchange database with the Windows esent.dll.

Thanks, martinc,

but what esent.dll you use if not Windows esent.dll (from system32)?

Developer
Nov 3, 2011 at 1:56 AM

skinder: Exchange uses ese.dll, which is similar to system32's esent.dll. But they are not identical, and Exchange's DLL is not documented on MSDN either.

-martin