Reputation: 1
I have localdb database with the name of golds.mdf
, when I take backup of it, it says it does not exist, even though CRUD operations work completely fine. But when taking backup, I get the error that it does not exits.
This is my connection string:
<add name="cs"
connectionString="Data Source(LocalDB)\MSSQLLocalDB;AttachDbFilename='|DataDirectory|\golds.mdf';Integrated Security=True"/>
Here is the code for taking the backup:
string fullPath = "";
string executable = System.Reflection.Assembly.GetExecutingAssembly().Location;
fullPath = (System.IO.Path.GetDirectoryName(executable));
AppDomain.CurrentDomain.SetData("DataDirectory", fullPath);
fullPath = fullPath + "\golds.mdf";
string insert = @"backup database ['" + fullPath + "'] to disk ='" + BackupPath.Text + "\" + currentdateInPer + ".bak'";
int r = database.setData(insert);
Upvotes: 0
Views: 79