Click here to Skip to main content
15,884,298 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.

VB
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        
        engine.Dispose()
End Sub


Regards,
Kapil Khurana



[Edit - Added code block, fixed spelling and grammar]
Posted
Updated 5-Apr-12 6:46am
v3
Comments
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. :-)

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