Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

We need to prevent the SQLServer 2008 .mdf file from being replaced by the end user of our application.

we collect data in the MDF that is important to us. If the user saves an old copy of the MDF, and then restore it at a later date, we lose that data. We want to prevent the user from doing this.

Is it possible, and if so, how could it be done?

share|improve this question

migrated from stackoverflow.com Nov 12 '11 at 19:27

This question came from our site for professional and enthusiast programmers.

3  
Not to put too fine a point on it, but the data is theirs, not yours. Why do you want to restrict their ability to manage their data the way they want to? –  Robert Harvey Nov 12 '11 at 17:45
3  
Can you elaborate why it is so important that the end user not replace the database? Give us your final goal instead of your current solution, we may have a better way. –  Scott Chamberlain Nov 12 '11 at 17:50
    
We sell devices actually, the data is ours. There is a table that gets fill with datas wich are important to us and we want to "protect" the data of that table to be deleted. –  user1043371 Nov 12 '11 at 18:33
    
If you give the user access to the files, they can do whatever they want. There is no way you can prevent that once the files are on the user's computer. –  a_horse_with_no_name Nov 12 '11 at 22:20

2 Answers 2

If you want to prevent the table from being deleted, see here: http://pratchev.blogspot.com/2007/12/prevent-table-drop.html. If you want to prevent the data from being altered by the end user, simply do not give your users modify permissions to that table.

If you set up your user accounts and permissions properly, changing out the MDF won't work, because the user accounts and credentials won't line up.

share|improve this answer
    
thanks, if I can prevent the MDF to be replaced with user accounts and credentials. Then that is all I need –  user1043371 Nov 12 '11 at 18:58
    
They can replace it, but the application will not function without the proper user accounts, credentials and permissions. –  Robert Harvey Nov 12 '11 at 18:59
    
But in this case, they can save a mdf file (with few datas), and restore it later when the current used mdf will be full of datas. And we would have lost the datas. –  user1043371 Nov 12 '11 at 19:18

If you sell devices and want to protect data in that device, then you should use an embedded database such as SQLite or SQL Server CE.

You have a client/server database engine that is external to your app. Therefore, the MDF is not under your control.

If you require an external engine and MDF to be under your control, then enforce it with the software license. There is no way to enforce what you want via permissions or software: it is isn't your PC or Server or network. It is your clients'.

Which leads to another question (off topic for this site).. .if you are collecting data and it is important, do your users know about this?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.