?
Solved

[C++] How to recovery dirty ESE file

Posted on 2013-12-30
4
Medium Priority
?
789 Views
Last Modified: 2014-01-01
Hello Experts,

I could attach ESE database file with followings..

#define _DATPATH "path to db file"

	jet_err = JetGetDatabaseFileInfo(_DATPATH, &db_page_size, sizeof(db_page_size), JET_DbInfoPageSize);
	if (jet_err != JET_errSuccess) {
		return;
	}

	jet_err = JetSetSystemParameter( NULL, NULL, JET_paramDatabasePageSize, db_page_size, NULL);
	if (jet_err != JET_errSuccess) {
		return;
	}

	jet_err = JetSetSystemParameter( NULL, NULL, JET_paramRecovery, 0, "Off");
	if (jet_err != JET_errSuccess) {
		return;
	}

	jet_err = JetCreateInstance(&instance, "instance");
	if (jet_err != JET_errSuccess) {
		return;
	}

	jet_err = JetInit(&instance);
	if (jet_err != JET_errSuccess) {
		JetTerm(instance);
		return;
	}

	jet_err = JetBeginSession(instance, &sesid, 0, 0);
	if (jet_err != JET_errSuccess) {
		JetTerm(instance);
		return;
	}

	jet_err = JetAttachDatabase( sesid, _DATPATH, JET_bitDbReadOnly);
	if (jet_err != JET_errSuccess) {
		JetEndSession(sesid, 0);
		JetTerm(instance);
		return;
	}

Open in new window


But if I tried to open the file that was dirty shutdowned (Application clashed),
JetAttachDatabase returns -550(JET_errDatabaseDirtyShutdown).

I set  JET_paramRecovery to "Off", because if it was set, JetInit failed.

How can I recovery that kind of "dirty shutdowned" file in my program ?
I know eseutil.exe will do that, but I want to do in my apps.

Any advice welcome !

Windows 7 32bit
C++Builder

Nobuo Miwa
0
Comment
Question by:NobMiwa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Duncan Roe earned 1500 total points
ID: 39747716
When JetAttachDatabase returns -550, I would system() out a call to eseutil.exe and then re-try the JetAttachDatabase call.
Database utilities do a lot of checking prior to clearing the dirty bits. You don't want to go there.
0
 

Author Comment

by:NobMiwa
ID: 39749177
Hello,

Thank you for advice.

I tried eseutil.exe manually and it works.
But I got some problems..

 - I could not find out 32 bit eseutil.exe that works with the database
   file that was created by Win 7 32bit.
   I tried to open ESE database file that was created with latest Win 7
   32bit system and that was not close clearly. I used eseutil.exe
   that was included in Exchange Server 2007 x86, and got version
   mismatch error. I manually /r(recovery) and /p(repair) with Win7 x64
   and eseutil.exe that was included in Exchange Server 2010 x64
   and works fine.
   I want to work my program with 32/64 bit both. So I need eseutils.exe
   that works with latest 32bit Windows created ESE database file.

 - When I call eseutil.exe with /p (repair), dialogue box pop-upped.
   I don't know how to run without that dialogue box.

Do you have any idea ?
Or is there any way to do with C++ (JetInit()...etc) ?

Any suggestions welcome.

Nobuo Miwa
0
 
LVL 35

Expert Comment

by:Duncan Roe
ID: 39749241
The only database I've worked with at all much is mysql. My experience there is that it should not matter whether you have 32 or 64 bit program. But if the software revision has changed then you need to run a once-only utility to upgrade the database.
Unless you really really know what you're doing, I would stay away from trying to fix it programatically.
0
 

Author Closing Comment

by:NobMiwa
ID: 39749524
Hello,

I found the solution.

http://managedesent.codeplex.com/discussions/225149

JetInit() could Recovery automatically and silently.

Thank you for the hint.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question