I have a Winforms application (checkers game) which have a local DB (using SQL Server Express)
to save the registered players and their scores..
I'm trying to create an installer for this app by this tutorial
Everything is fine, but when I'm trying to add the players I'm getting a SQL error
that says the database wasn't found.. so how can I add the local DB (.mdf file) to the installer?
Provided that the conditions to use local DB at the client machine are OK (see LocalDB deployment on client PC), in the deployment project you can just add the database files to the application folder (Choose File System Editor in the solution explorer when the deployment project is selected.
Side note: Are you aware of the fact that in VS2012 the MSI deployment project template is deprecated?
Addition: And it's back in VS 2013!
This is my workaround in wpf. I think solution is the same in Winform:
Make your mdf file "content" by right clicking on that and select properties. In "build action" menu select "content". And in copy to output directory select copy always
In Solution explorer go to Properties/Settings.Settings and put connection strings in a field (notice that name of that must be the same as it is in your App.config (eg in wpf) like picture below it will create).
Right click in your setup project and Add->Project output-> then select content files.
Related
I created a web application in VS 2015. It has basic authentication build in and is functional.
Where is the data for account authentication stored?
There are no files in the App_Data folder where the documentation indicates it should be located.
I'm looking to move the data to a SQL Server to be mixed in with other outside data. But I have to find the existing files first.
Thanks for any help.
Use any of these approaches, to access database files.
Click Show all files button from the toolbar on top of solution explorer pane.
Right click App_Data folder from Solution Explorer and select Open Folder in File Explorer from menu.
Identity database will be created in C:\Users\YourUserAccount\ and database name look like aspnet-YourApplicationName-Guid id.
I have deployed my application to server as below (from here):
To deploy an ASP.NET MVC application
In Visual Studio, open the project that you want to deploy.
In Solution Explorer, expand the References node.
Select the following assemblies:
System.Web.Mvc
System.Web.Routing
System.Web.Abstractions
In the Properties window, set Copy Local to True.
In Solution Explorer, right-click the project and click Publish. The Publish Web dialog box is displayed.
In Target location (http:, ftp:, or disk path), browse to a local folder and click Open.
Select either Replace matching files with local copies or Delete all existing files prior to publish.
Under Copy, select one of the following, depending on your needs: Only files needed to run this application, All project files, or All files in the source project folder.
If your application contains files in the App_Data folder such as database files, select Include files from the App_Data folder.
Click Publish. All the files that are required in order to deploy the application are copied to the target folder.
Afterward I have errors connecting database which was about loging failure which fixed. Then I face 500 internal server error.
I tried to enable debugging options and show errors which did not worked(here are the details).
I tried to do some blind tries, e.g. I created a control/view which its view just simply display an static output without any logic however it is still have 500 error.
I don't know how to fix this and how to continue debugging this project. What can I do know?
In the first installation in my WPF application I checked if the SQL database for my application exist or not, If not the application restore it from .bak SQL file.
When I publish my application I can't attach (Embed) the .bak file.
How can I do that ?
Thanks in advance
Abdusalam
Well .. I got the solution :
One good way of doing this is:
Create a folder under the app in VS name e.g. "datafiles"
Add all files to that folder using Add as link in the dialog box after selecting Add existing item on the folder
Mark all files as Copy if newer (Copy to output directory property)
Make sure the build action is content
--> when you publish the files will be put in that folder and be a part of the application installation
Good luck!
Source
I created a standard C# console application in 2010 Express, used the wizards to create a simple sql express db file which gets placed in the project dir, used the wizards to generate an entity data model based on the newly created db, wrote a few lines to test out entity.
Problem is each time I run the application it recreates the DB file in whatever dir the exe is in overwriting itself everytime and completly ignoring the original db file that sits in the project dir.
Does anyone know what I am missing here ?
Not entirely sure about this but try it out.
Make sure your connection string points to the database file in the project directory.
Select the file in Visual Studio and Choose 'Copy to Output Directory' ->> Do Not Copy.
Hope it works.
you must be using some way to find that file or some path parameter within the database connection that points to the database file.
Now either you can have that parameter be generated by code or make the directory specific and make the database file copy at a specific location from the original location so that the only that particular database is accessed using the application.
For doing that you can add another key in the application config file or at some other place so that the database your application is accessing is in the project directory itself at all times.
I am deploying C# windows application with an sql server database
This is the error I get when I deploy:
It says your database file is missing. Make sure you deploy the database file with your project.
See MSDN for more information. If you have your MDB file as part of your project, make sure that its properties are set to be deployed, specifically the Build Action (set to Content) and Copy to Output Directory(set to Copy if newer) properties. Your requirements may vary though.