Results 1 to 3 of 3

Thread: [RESOLVED] Compact and Repair Error?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Resolved [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!

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    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!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width