Click here to Skip to main content
15,065,644 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
Hi All,
While performing the engine.Compact("Data Source = " & destinationDBName & ";Password =" & encryptedPassword) line in the code below, I am getting this exception: “Attempted to read or write protected memory. This is an often indication that other memory is corrupted”.

This fuction is actually creating a new database using a old one and encrypting it with a password. And one interesting thing is that it's giving no error in my system, but giving exception in another system.

So, please help me out on this.

Public Sub GlobalFunctions_Encrypt_DB(ByVal sourceDBName As String, ByVal destinationDBName As String, ByVal encryptedPassword As String) Implements ICommonDAO.GlobalFunctions_Encrypt_DB
        Dim engine As SqlCeEngine
        engine = New SqlCeEngine("Data Source = " & sourceDBName)
        ' Compact the database and add password protection
        engine.Compact("Data Source = " & destinationDBName & ";Password =" & encryptedPassword) '***This line errors        
End Sub

Kapil Khurana

[Edit - Added code block, fixed spelling and grammar]
Updated 5-Apr-12 6:46am
wizardzz 5-Apr-12 11:16am
Please don't tell us that a problem is "Urgent"
This will be interpreted by some, if not most, of us answering to assume there is a lack of foresight, and a bit of getting involved in something over your head.
[no name] 5-Apr-12 12:48pm
Subject line edited to remove urgent.

This is a volunteer site and people will answer on their time not yours. Asking for urgent help is very rude and will be more likely to get you ignored.
Corporal Agarn 5-Apr-12 13:23pm
What are the errors?
Kschuler 5-Apr-12 13:41pm
OP listed the error in the first paragraph..“Attempted to read or write protected memory. This is an often indication that other memory is corrupted"
Corporal Agarn 5-Apr-12 13:54pm
Sorry about that. :-)
Maciej Los 7-Apr-12 14:07pm
I think it is Access. Which version?
ssd_coolguy 14-May-12 5:47am
i think this issue might be access issue...because used password is in encrypted format.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900