stack, I need help, JetAttachDatabase returning error -550. JET_paramRecovery is switched off. What should I do that it starts work?
I've already tried to restore instance, but I have no restore file... I don't know what should I do. Now I have code like that
sWebDataBase.err = JetGetDatabaseFileInfo(sWebDataBase.path,
&sWebDataBase.dbPageSize,
sizeof(sWebDataBase.dbPageSize),
JET_DbInfoPageSize);
ErrCheck(sWebDataBase.err, "JetSetSystemParameter, JetGetDatabaseFileInfo");
sWebDataBase.err = JetSetSystemParameter (&sWebDataBase.instance,
JET_sesidNil,
JET_paramDatabasePageSize,
sWebDataBase.dbPageSize,
NULL);
ErrCheck(sWebDataBase.err, "JetSetSystemParameter, JET_paramDatabasePageSize");
sWebDataBase.err = JetSetSystemParameterW(&sWebDataBase.instance,
JET_sesidNil,
JET_paramAlternateDatabaseRecoveryPath,
NULL,
L"C:\\Users\\Chrnykh\\AppData\\Local\\Microsoft\\Windows\\WebCache\\test1.dat");
ErrCheck(sWebDataBase.err, "JetSetSystemParameter, JET_paramAlternateDatabaseRecoveryPath");
sWebDataBase.err = JetSetSystemParameter (&sWebDataBase.instance,
JET_sesidNil,
JET_paramRecovery,
NULL,
(JET_PCWSTR)"On");
ErrCheck(sWebDataBase.err, "JetSetSystemParameter, JET_paramRecovery");
sWebDataBase.err = JetInit (&sWebDataBase.instance); //------------------------------------JetInit
ErrCheck(sWebDataBase.err, "JetInit");
sWebDataBase.err = JetBeginSession (sWebDataBase.instance,
&sWebDataBase.sesId,
NULL,
NULL);
ErrCheck(sWebDataBase.err, "JetBeginSession");
ErrCheck(sWebDataBase.err, "JetRestoreInstanceW");
sWebDataBase.err = JetAttachDatabase(sWebDataBase.sesId,
sWebDataBase.path,
JET_bitDbReadOnly);
ErrCheck(sWebDataBase.err, "JetAttachDatabaseW");
sWebDataBase.err = JetOpenDatabaseW(sWebDataBase.sesId,
sWebDataBase.path,
NULL,
&sWebDataBase.dbId,
JET_bitDbReadOnly);
ErrCheck(sWebDataBase.err, "JetOpenDatabaseW");
You shouldn't have to set JET_paramRecovery
. It defaults to on. Try removing that. You also set it to "On"
in the code, but your question says it was set off. It's also not a good idea to disable it, because if you modify the database and crash, then the entire database is unusable at that point. This is acceptable for a very small minority of people.
Instead of setting JET_paramAlternateDatabaseRecoveryPath
, you should set the Logging path.
When you call JetInit
, the database engine will examine the current log stream, and replay the operations if necessary. You'll need to set the logging directory, as well as the Checkpoint file location (confusingly called "System Path"). Then it should be able to replay the log files successfully. You may also need to set the "Log file base name", which defaults to "edb", but it can be set to any 3-character sequence.
You can also use the command-line utility esentutl.exe
to replay the logs first. Use it by changing in to the directory of the log files, and running a command like esentutl.exe -r edb
.
Does that make sense?