i am stuck with SQL Database and its location (In Windows Application Project C# 2010)
Now i mad an Application with VS.net C# 2010 express edition and using SQL express also, i used in my solution data explorer to create and mange tables of DB and this is my connectionstring:
<add name="FamilySystem.Properties.Settings.FHDBConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\FHDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
and i place my DB in that Directory :
AppDomain.CurrentDomain.SetData("DataDirectory", "C:\\MyApp");
1-but now if i want to make backup for the DB the error appears and say : this database doesn't exists, so i can't also make restore for it.
2-what is the bet location to p开发者_如何学Pythonlace my database and what about the "Copy to output Directory proprieties" what is the best value for it??
i want to know what the wrong because i have stucked with that since month ago and i can't figure out how to solve it really i need your help and support :S
thanks in advance if you want to know more tell me
You should place you sql files in Data folder of application. so you do not need to set data folder in your application.
then you can do any thing you want. just right click on your project and add a data folder. specially if your project is an asp.net project.
bu the easiest way is to set your connection string like this :
<add name="FamilySystem.Properties.Settings.FHDBConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\MyApp\FHDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
精彩评论