开发者

JetInit returns -1213 if I change the PageSize

开发者 https://www.devze.com 2023-02-09 00:56 出处:网络
I am trying to read into some existing and unmounted esent database files (like Windows.edb). I have been playing around with some edb files rather successfully. But when I try to open a database with

I am trying to read into some existing and unmounted esent database files (like Windows.edb). I have been playing around with some edb files rather successfully. But when I try to open a database with P开发者_如何转开发ageSize that is not equal 8192 I get an error.

Here's my code (without error-handling):

FError := JetSetSystemParameter(@FInstance, nil, JET_paramDatabasePageSize, FPagesize, nil);

FError := JetCreateInstance(@FInstance, 'EDBInstance');

FError := JetInit(@FInstance);

FError := JetBeginSession(FInstance, @FSessionId, nil, nil);

FError := JetAttachDatabase(FSessionId, FFilename, JET_bitDbReadOnly);

It works fine as long as FPageSize = 8192. Any other value (4096, 32768) fails at the JetInit call which returns an -1213 code. If I don't set the proper PageSize value for the database I get the same error at JetAttachDatabase, which I can understand. But the first error that gets returned by JetInit I fail to comprehend. What do I do wrong? I hope Laurion Burchall is reading this! :-)

I am running a Windows 7 64bit.


There are two possibilities:

  1. The database you are trying to open has an 8Kb page size. Use ESENTUTL /M database to see the page size.
  2. The page size is always persisted in the logfiles, which are created by the JetInit call. If you don't clear out those files between runs then you will get a -1213 error when calling JetInit with a different page size.

If you want to open an existing database in a read only way then you should turn recovery off (set JET_paramRecovery to "off"). That will prevent any logfiles from being generated which will avoid a lot of problems.

0

精彩评论

暂无评论...
验证码 换一张
取 消