[RESOLVED] Compact and Repair Error?
Hi Peeps,
Here is my code to compact and repair a SQLCE database:-
Code:
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!
Re: Compact and Repair Error?
Okay I have sorted my first problem by leaving the connection string blank; this simply repairs the database without outputing to a new file.
My next problem is once the repair is complete is seems to remove the password for the database; how can I add the password back?
Regards,
Roger
Re: Compact and Repair Error?
Managed to sort it; when you repair or compact you specify the datasource=; and then add the password as password=324234234; as the connection string
datasource=;password=43534345;
Hope this helps others!!!!