Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Answer
Service-based Database in visual studio 2010
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
jitendra yadav
9y
942
1
Reply
Hello developers,
Actually my problem is, I made a project in c# with service-based Database. Everything is going good. But I am stuck with backup and Restore process.
I have done Backup and I got databasename.bak file But I don't know how to Restore that BAK file in service-based Database.
If possible please tell me that is it possible and if it is then please tell me how to do that. Is there any third-party software that I have to use or is it done by Code.
if (sqlcon.State != ConnectionState.Open)
sqlcon.Open();
string destinationdb = Application.StartupPath + "\\Database1.mdf";
string query = "USE [master]; RESTORE DATABASE [" + destinationdb + "] FROM DISK = N'" + "d:\\svBackUp1.bak" + " ' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10";
SqlCommand cmd = new SqlCommand(query, sqlcon);
int b = cmd.ExecuteNonQuery();
if (b> 0)
{
}
this is the code which I am using for restore but I got error..
"Exclusive access could not be obtained because the database is in use.
RESTORE DATABASE is terminating abnormally.
Changed database context to 'master'."
Not Resolve... Please Give me another solution.....
Thanks
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
burn setup to cd
I got Network related error