Jigabyte
Jan 8th, 2010, 05:06 AM
Hi Peeps,
Here is my code to compact and repair a SQLCE database:-
Dim sCompact As String = "Data Source=/Program Files/PocketAudit/PocketAudit_C.sdf; Password=jiga2007; Encrypt Database=True"
Dim database As New SqlCeEngine(CeLocalConnectionString)
If Not database.Verify Then
database.Repair(CeLocalConnectionString, RepairOption.DeleteCorruptedRows)
database.Compact(sCompact)
IO.File.Delete(CeDataBase)
IO.File.Move("/Program Files/PocketAudit/PocketAudit_C.sdf", CeDataBase)
End If
It would seem that there is a problem with the database because the verify fails and when it goes to database.repair it produces and error saying the database filename already exists. Is this because it is trying to recover the corrupt rows in a different database. I would of thought not.
Thanks for any help,
Jiggy!
Here is my code to compact and repair a SQLCE database:-
Dim sCompact As String = "Data Source=/Program Files/PocketAudit/PocketAudit_C.sdf; Password=jiga2007; Encrypt Database=True"
Dim database As New SqlCeEngine(CeLocalConnectionString)
If Not database.Verify Then
database.Repair(CeLocalConnectionString, RepairOption.DeleteCorruptedRows)
database.Compact(sCompact)
IO.File.Delete(CeDataBase)
IO.File.Move("/Program Files/PocketAudit/PocketAudit_C.sdf", CeDataBase)
End If
It would seem that there is a problem with the database because the verify fails and when it goes to database.repair it produces and error saying the database filename already exists. Is this because it is trying to recover the corrupt rows in a different database. I would of thought not.
Thanks for any help,
Jiggy!