How to deploy the win-form application with the .mdf file,i have taken the setup file and also add the .mdf file and .ldf file, when running in visual studio its working fine after taking the setup the record its not showing.Even not saving also in the database after taking the setup file. How to attach the database with my setup file.Any ideas...
the database mdf file is not a project output file. So, you can move it to resources and add resources from the project output window or your can directly add in application folder from the Application Setup Wizard.
Select the file from the Browsing File Dialog window. If you would like to add all local resources in the setup file then you can select Localize Resources from the project Output window.
//"Data" folder should be created in Application Folder path
String DBPath = Application.StartupPath + "\\Data\\CMM.mdf";
String ConnString = String.Format("Data Source=.\\SQLEXPRESS;AttachDbFilename={0}; +
"Integrated Security=True;User Instance=True", DBPath);
SqlConnection con = new SqlConnection(ConnString);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With