Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
Working on a VB.NET project with SQL LocalDB I'm having the next problem:

When deployng on a client machine (Windows 7), my application tries to Create a DB on disk but it got ERROR 5 (Access denied) ... (It seems SQLLocalDB does not have write permissions on disk)

It suppose I have not chance to manipulate that machine. I just send a SETUP that contains the program and SQLLocalDB as prerequisite.

How can I solve this issue from code since I cannot access to client machine?

Thanks.
Posted
Comments
[no name] 30-Jun-15 10:10am    
Make sure that the file is read/writeable before you create the setup. You could check the file before you use it and change the file permissions. If the user is installing it in Program Files then the OS is going to tell you that access is denied.
Michael_Davies 30-Jun-15 10:34am    
Show the create statement, which directory are you trying to use.
Member 11757010 30-Jun-15 16:02pm    
The program is installed in Program Files and it tries to create a DB in Application.StartupPath.

That must be the problem.
Michael_Davies 30-Jun-15 17:00pm    
Definitely, that will either be C:\ or the program files directory where you do not have permission.

Use one of the SpecialFolders and create a subfolder for your application, usually the application name, like myfolder=Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))+"\" + myapplicationname

See:

https://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx

Just checked and ApplicationData has been superceeded by LocalApplicationData

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