Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I've created a database windows application using C#.net.My application is running successfully in windowsXp, but it doesn't properly execute in vista/Windows7 systems.
My application shows a message like "Failed to update .mdf database because the database is read-only" Any one give me a proper solution.
Posted

First of all:
Any one give me a proper solution.
Well, define 'proper solution'. After that, no need to use bold for it. If you have an issue and you are here for help, please be a little respectful.

Now:
"Failed to update .mdf database because the database is read-only"
A simple Google search[^] could had given you many links like this:
Similar discussion[^]

based on what you say, and the discussion link above, Win7 & Vista has some extra security layer and you need to give proper permissions to the user who is trying to access the database. It's a security configuration issue.

(BTW, I think, you should get the details of this privilege issue in EventViewer logged as an error.)
 
Share this answer
 
Comments
ambarishtv 19-Apr-11 4:27am    
Sorry for my bad english.
How to overcome this security configuration issue.
Sandeep Mewara 19-Apr-11 4:37am    
Did you go through the link I shared?

Further, looks like, Dylan Morley provided you a link. Did you went through his answer too?
Bound to be a permissions issue with Vista not allowing access to \YourProjectPath\App_Data

1) Make sure App_Data directory or any contained files does not have file system attribute Read-only set.

2) Make sure the user account you are attempting to connect with has modify control over the App_Data directory.

Have a look at this thread[^] which has a full step-by-step (that's for ASP.Net, but the principal is the same - just choose a different user account at the end)
 
Share this answer
 
Hi,
"Failed To Update .mdf Database." Some months before while in a windows project i came through this problem.
I googled enough and found some vital informations which i like share on this topic.

I'll put it one by one for easy understanding.
No matter whether its XP, Vista or Windows7. The Solution is all the same.

1. Just go to the program files and find the folder of the installed program.
2. Just right click the .mdf file in the folder and click PROPERTIES.
3. In PROPERTIES TAB -> SECURITY -> you'll see Group or Usernames.
4. In that select the User to which u want to give Access to the file.
5. If for that user the PERMISSION is not set to FULL CONTROL.
6. TO CHANGE PERMISSIONS -> CLICK EDIT.
7. Now the Group or Username box will open.
8. In that Select The User -> Select FULL CONTROL in Permission Box.
9. Now follow the steps for the log file too. IF Needed.

Now it'll Work..


Thank U,
RAJASEKAR KALIDASSAN
 
Share this answer
 
v2
Comments
Member 12175264 4-Jan-16 1:45am    
Thanks it works...
AshuRevgade 4-Apr-16 2:47am    
thaks..
Member 12456565 19-Jun-16 7:03am    
Thanks
Member 12456565 19-Jun-16 7:07am    
Hi Sir,

I am new wit C#, I am getting the same problem of "Failed to update database",I aslo follow the steps also but the user is already have FULL CONTROL allow to Read, Write etc...but still I am getting this error. Please suggest.
right click on your database in object explorer. select properties. under select a page, select page named Options. set "database read only" property which is under "State" option to False.
 
Share this answer
 
Comments
ambarishtv 19-Apr-11 4:48am    
Thanks for replay
Database is not in object browser in visual studio.
I got answer...
Moving the data(.mdf)to the ApplicationData shared folder, where end users will have write permissions by default.

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString) this code is used to find out the Application folder path in xp,vista,win7

Thank you all..
 
Share this answer
 
Provided the database is TFS bound, then it should be checked out, or have the read-only flag unset.
 
Share this answer
 
it not working on windows 7.


please help me.



thanks in advance
 
Share this answer
 
Comments
[no name] 14-Apr-12 6:26am    
This is not an answer to this year old question. If "it not working on windows 7", whatever "it" is, then ask your own question.
Publish your website without publish copy of App_Data folder
finally copy&paste your developer copy of App_Data folder > webserver
 
Share this answer
 

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