WPF Desktop Application with MDF used locally for all local users - sql

I am using Visual Studio 2013. I have all components installed on my machine needed to run this application I am questioning. I have not completed the application to deploy for testing but some questions arose before completion that I need addressed now; to prevent overhauling later.
Here's how it should work when deployed to clients.
Client installs application which runs on desktop not windows store in WPF.
The application is per user and runs for all users on the local machine.
Each user needs to read and write data to a database file but it needs to be the same MDF being used. Therefore each process of the application, no matter the user session, on the same machine, all interact with the same database / same data.
Question: When adding the database to the project where will it be installed by default? In the applications program folder along with program? If so what restrictions exist to read/write to the database and are there any? I have added no extra security on my side. The info isn't private or critical.
Question: Would end users need to install any sort of SQL in order for the application to do this? If so I can package it with the install but this seems like alot of overhead during install.
If the MDF is installed per user how do I change this to install it once for all users?
Before saying so, yes this needs to be a database and not a file. Reasons I need not describe. I have considered alternative but this is by far the best solution so please no alternatives.

When you add mdf file to your project and set properly the value of Copy to Output Directory, it will be copied to the bin directory of your project whenever you build the project. When you create setup project for your app project, it will be by default copied to the folder where your app is installed. You can either specify different location in your setup project or copy the file to the desired location during the first run of your app.
There are several suitable folders in Windows, one possible choice is %PROGRAMDATA% C:\ProgramData folder, but it is by default read only for non-admin users. If you do not worry about security, go for %PUBLIC% C:\Users\Public. It is completely accessible for all users within interactive group.
I recommend to package LocalDB with your project. It can be installed silently with one line of code, though only with admin privileges. For non-admin click-once install you would have to use SQL CE, which is quite different and uses sdf files.
I think you should do it this way: include a seed database MDF file in the application and copy it to a %PUBLIC%\YourApp folder when the application first launches. Optionally include LocalDB install in your setup project.

Related

Ms Access data still in database after Uninstall

I have an App that was designed with Vb.Net 2010 and it uses Ms Access 2007 for its database.
The program executes fine but I found something funny when I uninstalled the program and re-installed it, data that I entered before I uninstalled are still in the new database even when the re-install action copies a fresh database to the location. I checked to see if the uninstall action deletes the database on uninstall, and I found that it deletes everything including all folders. I don't know if it is somehow caching somewhere or something.
I am using Inno Setup Compiler for my install script, and there are no instructions to copy the database anywhere else apart from the default location.
My connectionString in the app points to the App Folder where the database is located.
I have checked online and I got unrelated result (maybe I don't know the correct keyword to search for).
Please, can someone help explain what is happening and possible solution?
I need help, thanks.
It appears that you are being fooled by User Account Control (UAC) virtualization. You have apparently stored your database file under %ProgramFiles% and users do not have read/write access to those folders, so Windows makes a copy of the file in a subfolder of
%USERPROFILE%\AppData\Local\VirtualStore\Program Files
and redirects read/write operations to that copy.
When you uninstall your application the installer probably runs under elevated privileges (via the UAC prompt) and removes the original copy of the database file (in %ProgramFiles%) but the virtualized copy remains. Then when you reinstall (again, with elevated privileges) the original file gets copied back into %ProgramFiles% but the (modified) virtualized copy is already in place so you see the old data from before.
Moral: If your application needs to make modifications to the database file do NOT store it along with your application files. Have your installer put it somewhere where users normally have read/write access, e.g., under %USERPROFILE% for individual users, or %PUBLIC% for multiple users on the same machine.

How to get database working when i install my project in other system

Okay I have created my project in Visual Studio 2012 express edition. I have used ClickOnce Application deployment to create a setup file. Everything works absolutely fine when i run the project in my computer. But when i install the same project in another computer database connections are not working saying path is not correct. I understand that the path given to connect to the database is of my system. Now that is my problem and what should i do to make the database stuff to work in other systems as well? Please help me as this would make my project complete!
Thanks in advance.
Generally the application would be deployed with an app/web.config. Or another configuration file. Your code then reads the connection string out of this file to find the database.
On deployment, you can change the config file after deployment, this can be done manually, or in IIS if its a web config file, not sure on automatic editing with click once deployments; but a config file or setting of some kind would be key.

Microsoft Visual Studio 2005 (Vb.net)

I'm doing my project in Vb.net. my project name is "Bellows". My front end is Vb.net. Back end is Ms Access.
i Create My project in Windows Application
i complete my project. i copy the .exe file from "E:\BellowNet(new)\Bellows\obj\Debug" and put the shortcut into my desktop. now it's running.
similarly i copied my Bellows.exe from another system desktop but it not running.
How i want to run my Bellows.exe from another systems (maximum 10 systems).
Note : In my system only having Microsoft Visual Studio 2005. Remaining system doesn't have.
I put bellows.exe from another system. in that system doesn't having E Drive. it showing this error
The application Filed to initialize properly(0xc0000135). Click Ok to terminate the application
Similarly I put bellows.exe from another system. in that system having E Drive.
if i click that Bellows.exe the login form is open.. and main form is open. in that main form wen i click button it show the error.
Unhandled exception has occurred in your application. If u click continue the application will ignore this error and attempt to continue. If u click Quit, the application will close immediately. Could not load file or assembly ‘ADODB, Version=7.0.3300.0, Culture=neutral, PublickeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified
Good practice to run your project on another systems is to create its setup file and then install it on to another systems on which you want to run your project and of course you need to install .NetFramework as well with the same version which you used to developed your project. How to create setup and how to add Serial Key for those steps refer my blog
It sounds like either the .Net Framework is not installed on your target system or that there's an app.config file (Bellows.app.config) that you need to copy over as well.
Another thing that concerns me is what your expectations are for the access database. Do you want all the workstations to share a common database? If so, I highly recommend you convert your app to use Sql Server Express Edition (free). Access is an in-process database engine, and like all such engines it doesn't behave well when shared. If you don't expect them to share the database, you probably want to make sure you copy that *.mdb file over to your target machines as well.
Finally, let me re-iterate the advice in other answers about using a Release build and/or deployment project.
What errors do you see?
It could be:
The other system does not have .Net
framework 2.0 installed
You copied only the exe from the dev machine without other required files from the Debug directory (e.g., app.config, supporting DLLs).
If you are going to copy and paste the exe file then the all Prerequiest should be installed on that machine like framework.So make a setup file which is easy and add all Prerequiest on the setup after that do setup on new machine..
Thanks
I can only guess, but try this suggestions.
The application Filed to initialize
properly(0xc0000135). Click Ok to
terminate the application
.NET framework is not installed on this machine. Install the runtime.
Could not load file or
assembly ‘ADODB, Version=7.0.3300.0,
Culture=neutral,
PublickeyToken=b03f5f7f11d50a3a’ or
one of its dependencies. The system
cannot find the file specified
ADO.NET drivers are missing. You need to install Microsoft Data Access Components
You can avoid this problems if you make an install procedure and do the proper install on every machine.
The appropriate .NET framework must be installed in each machine as well as the appropriate MDAC. You can add them as part of the installation package.
http://msdn.microsoft.com/en-us/library/ms994427.aspx
And if you want to make it even more easier for your clients to get hold of it; use ClickOnce to distribute it from a central server.
http://www.15seconds.com/issue/041229.htm

Shareware vb.net application packed using innosetup, installed in different directories creates 2 different set of application

I have created an shareware application using vb.net visual studio 2008 for windows desktop, and packaged it using innosetup 5.3.8. The problem is when i have installed the application in C:\Program Files\Application and it runs successfully(use trial period of the application), Im also able to install the application once again freshly with the same setup by installing in different directory.eg C:\Program Files\Application new . The application in C:\Program Files\Application new does not have any settings of the already installed one.
Where do i went wrong . Do i need to take care of this in my application(vb.net) or innosetup. How to take care of the already installed path in innosetup or carry the settings of already installed application to newly installed path by upgrading the older one.
I dont want to write any thing in registry because the application does not want any administrative permission requirements.If i install the application in same path it gets updated with the older settings being taken over to this new one and it works fine.
Windows applications normally save their settings in the registry under HKEY_CURRENT_USER\Software\YourCompany\YourApp or as files under %APPDATA%\YourCompany\YourApp. Both locations can be written to without admin privileges, and both locations are user-specific. That is, if two users use the same computer, both can use your application with their own settings without affecting the other user.
You should never save any settings under c:\Program Files. Writing to the Program Files folder requires admin privileges. If your application does not have a manifest then writing to Program Files may appear to work. What is really happening is that the files you're writing to the Program Files folder are rerouted to the VirtualStore. Unless the system administrator has disabled the VirtualStore. Then your application will fail.
If you want your application to be robust, it should only save settings to HKEY_CURRENT_USER\Software\YourCompany\YourApp and/or %APPDATA%\YourCompany\YourApp. Your application should use its default setting if no previously saved settings can be found in these locations.

Why Setupper created by Publish feature does not copy files to c:/PROGRAM FILES

I have VB project and I tried to use PUBLISH feature.
It seems to create nicely some kind of setup program, but the setup program does not ask where to copy files (it does not seem to copy filesto target machine "PROGRAM FILES".)
Is this setup program somehow different from usual installers?
NOTE: I want that app files are installed to Hard disk( from USB stick source)
Is the signing recommended or necessary? My App is pretty simple, its just using access DB + printer api, should I still sign?
The "Publish" feature creates a ClickOnce installer. Such applications are installed per-user instead of per-machine, i.e., they are installed somewhere into the user's profile. This is by design and has the advantage that the user installing the software does not need administrative privileges on the machine.
You can also create a setup project by going to File/New/Project/Other Project Types/Setup and Deployment/Setup Project. This creates a "conventional" MSI-based installer, offering the "classic" C:\Program Files type of installation.
On MSDN, two approaches are compared here.
Our biggest problem in-house is privleges.Does the "user" have access to write to "Program Files"?