I have a WPF application including a SQLite Database.
Everything worked file as long as the computer was Win 7.
Since the PC is Win 10 I cannot write the database anymore because it is installed in C:\Program Files (x86)\ProgramName.
If I understood that right I need admin rights to write to the database in this folder. But if the program is started as administrator Drag&Drop is forbidden which I also need.
The first Idea would be to copy the database to C:\Users\\AppData\Local. There I have write access even without admin rights. But the use case of this database is that different Users on the same PC can enter this database. Thats not possible anymore if the db is installed in a personal folder.
Do you have any suggestions?
Related
two days ago my laptop fall off from table. I've window 7 installed. My windows is not starting in standard mode I can only get access via safe mode. I was doing a c# project in Microsoft visual 2012 and it was almost completed My problem is that I cannot see project files using safe mode. Is there anyway to access the source code or project so that I can send it to other laptop?
I want to copy my code so that I can complete my project in other system?
First, right click on the folder that you want to get files from. Go to security tab, and make sure the admin account you are using has full rights to the folder. They may be not appearing because there is some weird permission things happening.
You may be able to connect to a USB or External HD while in Safe Mode, and then just copy of the files over and put them on another computer with VS 2012. If not, try Safe Mode with Networking and then try to upload to Dropbox/Onedrive.
In desperate times, you can always buy a HD mount device, pull out the HD from the computer, mount with HD mounter on another computer, and copy files over.
I recently bought a software that uses an mdb file for data storage. I don't like the software's reporting and statement generation that much so I decided to write my own reporting program using VS 2008's C#.
So my program accesses the mdb file that comes with the software I just bought. My dev environment is Windows XP. My deployment environment is Windows 7 64-bit. In my dev machine, I can retrieve records from the mdb file just fine but when I deploy the program to a Windows 7 64-bit machine, it cannot read the records from the mdb file. No errors are thrown, it just can't get that data.
I also tried installing VS 2012 on the deployment machine (Win 7 64-bit) and imported my VS2008 project there. Same issues, can't get records from that mdb file (again, no errors are thrown).
Please help?
edit 1: I just tried backing up the mdb using the purchased software backup utility. I can retrieve records from that backed up mdb. I wonder if the software is trying to modify my access to the mdb file.
edit 2: I don't think the software is trying to modify my access to the mdb file because when deployed to my xp machine, I can access the mdb file just fine.
edit 3: I'm beginning to suspect this is a file security feature within Windows 7.
edit 4: If I copy the mdb file and access that copied mdb file, it returns 0 rows. If I back it up using the software's backup utility, it returns the exact rows I expect.
The problem is that you're running up against security features of Windows.
Programs are no longer allowed to change files under the program files directories, unless they run with elevated access.
What happens is that a feature called Virtual Store kicks in and creates private (for your user) copies of the file somewhere else, under your user profile.
Most likely the software has created an empty database file under the user profile, and is accessing that instead.
You can not place writable files in the program files any more, the program needs to be either redesigned or installed somewhere else, like under the user profile where it would have write access.
Set your target platform to "x86" instead of "Any cpu" to be sure that you are running it 32-bit.
I have created a Winforms app that writes all data to a SQL Server CE database. I am able to successfully install the app but when I try to read or write data, it tells me that it cannot open the connection. This only happens on PC's other than the one I created the program on. Nothing is hardcoded.
Does anyone have any suggestions?
Thank you
Windows will fight you with permission issues for locating the database in the Program Files directory. It doesn't belong there.
Consider moving the database to your own folder in this root folder:
Environment.SpecialFolder.ApplicationData
Obviously, the connection string needs to reflect that folder path.
I have built a Windows Forms application using Visual Studio 2012 and MSSQL 2008. I need to deploy this project using InstallShield Limited Edition.
While running this application on my pc, it does nto work well when I use the following connection string or .//SQLEXPRESS.
I need the installer to find the exe file of the application on other uer's pc with the database file. Where do I need to put my database files in the deployment files folder? What should my connection string be?
i use .//SQLEXPRESS it doesnt work as well
DO NOT use .//SQLEXPRESS as datasource name in the connection string.
Recommended way is to menthion Instance Name if your application is to be deployed in different environments(especially OS). I ran into trouble when I had the Datasource as .dot which worked in Win 7 not in WinXP. Either one of the following approach works fine.
(local)\SqlInstanceName
(ComputerName)\SqlInstanceName Ex: CD-SJHONES\SQLINSTNACE
In certain cases i had to include the computer name, So during the application deployment i get the computer name and update the connection string accordingly.
where i need to put my database files in deployment files and folder
and what should be my connection string
Connection string
I have already answered connection string releated question above.
Database files
What do you mean by database file. how database is created in the client machine ? do you create a database during application deployment or users manually create it with script ? There is nothing to worry about the database fine as long as your application have right connection string to point to your database.
Application files and folders
Again this doesn't really matter where application files and folders resides in the client machine. It's upto the users to decide where he/she likes to install the application.
You cannot install from backup. Also in your scenario, you should force end user t install Sql Express, what If it has already installed. So You need considering , scripting of entire database. You can create another exe / look for option in Installshield to execute that Script incase the database server is found else, force user to download the Sql Sever Express or Embedd it into setup and execute the script over there. But that will make your Setup Size more than 100's of MB.
I have a program that needs to create a text log. In XP, everything worked just fine, but when I tested it on Windows 7 - and was later Upgraded to Windows 7 for my Dev Computer - I get an error that "Access to the path 'C:\Program Files (x86)\Ludlum Measurements, Inc\LMI Universal Software\UniversalLog\' is denied". I get the a similar error if I have the installer create the folder and then try to create a text file in the folder.
I know this has something to do with permissions, but what should I give permission and how?
The programs that use the logging function?
The folder that the logs go into?
The folder the programs are in?
And how would this fix work under XP, Vista, Server 2005, and Server 2008 and as service (Part of the program runs as a Windows form, and part as a service)?
-Edit-
Emphasis added.
To reiterate: How will this work when installed and ran on an XP? A Server 2003? A Server 2008? Will this cause any problems for them?
And a new question: Can my program access files from the ApplicationData file? I just remembered the entire problem stemmed from me trying to create a config file that holds connection information for to an SQL database. Hitting your head against a brick wall for a day tends to make you forget why you started doing it in the first place. And again, this originally worked in XP, Server 2005, and Server 2008.
You should use Environment.GetFolderPath and pick a Environment.SpecialFolder folder that has write permissions when the UAC is on and write your log files there.
By default under UAC you donot have permissions to write to C:\Program Files or its subfolders.
Environment.ApplicationData is usually a good choice, it will be writable by default on XP , Vista , Server 2005 and Server 2008 unless the admin has locked stuff down too much
Teach Your Apps To Play Nicely With Windows Vista User Account Control is a good resource on how to write an application that behaves nicely under UAC
You shouldn't write anything to the Program Files directory after installation unless you are actually patching your application. Day-to-day usage of files should go into the application data folder (LocalApplicationData for non-roaming data and ApplicationData for roaming data).
string path = Environment.GetFolderPath(
EnvironmentFolders.SpecialFolders.LocalApplicationData)
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx