Tuesday, March 20, 2012

Recover SDF-File

Hi,

we're using SQL Server CE 2.0 on our CE 4.2 device (mobile scanning device).
In some cases, the application freezes and the user must perfom a cold boot.

After the cold boot, the database is some kind of corrupt - the application can't build up a new connection and a "Fatal Applicatio Error ...." is thrown.

If you try to connect to that SDF-File via the Query Analyser Tool, it also throws an exception .... "DBInitiliaze"....

Do have anyone an idea whats wrong with the SDF-File and more important: How could we recover such files - most times there is already business data stored, which would be than lost...

Thanks
WilliBaldDid you try compacting the SQL CE 2.0 database.

Thanks,
Laxmi|||Hi,

sorry - I can't follow you - what do you mean with "compacting"?

I fare as I understand, the SQL Server CE 2.0 database stores its data in such *.sdf files and I'm not aware, that we compress or compact them in any way - the problem is, that if the application freezes when you perform a database action, the database falls in some stage, where you even can't connect with the QueryAnalyzer - as if the *.sdf file is still open...

Thanks
WilliBald|||

There could be an option in ISQLW tool before connecting to a database do "Repair & Connect".

Thanks,
Laxmi NRO, MSFT, SQL Mobile, Microsoft Corporation

|||The easiest way to kick off a Compact on an .sdf file is to use the
"SQLCE Database Viewer" tool.

Aswell as letting you view & edit your SQLCE2.0 and SQL Server Mobile
databases from your Desktop, this has a friendly ActiveSync Explorer
style front-end, and you can literally right-click on an .sdf file, and
select "Compact.."

You don't have to tap on your device's screen once !
It doesn't get much easier than that...

www.pocketpctoolkit.com
Mike
|||WilliBald,

With SQL CE 2.0, the only option available to attempt to repair a database is to call Compact on the SqlCeEngine object. Compact verifies database integrity, reclaims unused space, recalculates index statistics, etc. Unfortunately, if you cannot Compact the database, there is little else you can do to recover it. With SQL Mobile, this improves with the addition of Verify and Repair options on the database engine.

In most cases, SQL CE databases that I have seen become corrupted are on storage cards or other removable storage.

-Darren Shaffer|||Hi Mike,

thanks VERY much!
The tool is great and I've managed to restore the database files!

One more question: Is there a chance to get the mobile binaries also for SH4 processor? - Cause we have devices with that typ of cpu.

regads
willibald|||

hello Mike,

I read your answer and i download the same viewer and its really helpful. But still i am not able to compact my database. whenever i use compact database option it keep trying and doing nothing at the end. Even i wrote my own application to do so using Data.engin etc, but still unable to recover my database .SDF file.

Kindly tell me is there any clue to rectify this ?

Thanks in advance

|||

I have had the same problem with a corrupt SDF file.

All I did was Compact it.

Encrypt it again.

All works fine.

No comments:

Post a Comment