Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL C#4.0 database Backup
How can i create the backup of sql database by c# code. Any sample code.
 
I am using this command to backup,it' snot working.
 
 cmd.CommandText = @"backup database tryDatabase.mdf to disk ='d:\BackUp1.bak' with init,stats=10 ";
Posted 1-Oct-12 9:09am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

This post might help you :
 
LINK
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
footballpardeep at 1-Oct-12 15:34pm
   
Thanks for reply, i don't want to use any dll for this. i wanna do it by sql command.
footballpardeep at 1-Oct-12 16:03pm
   
I was not using initial catalog in connection string.
when i used this:
string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\PARDEEP\Documents\Visual Studio 2010\Projects\TryingDatabaseInWPF\TryingDatabaseInWPF\tryDatabase.mdf;Initial Catalog=tryDatabase;Integrated Security=True;User Instance=True";
 
It worked.
footballpardeep at 1-Oct-12 16:04pm
   
But now the problem is how can i restore the database.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi footballpardeep,
 
Why you didnt ask google about it?
I hope this link[^] would help you a bit.
 
Regards,
RK
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 921
1 OriginalGriff 425
2 CPallini 255
3 George Jonsson 181
4 Richard Deeming 175
0 OriginalGriff 5,450
1 Sergey Alexandrovich Kryukov 4,532
2 CPallini 4,500
3 George Jonsson 3,102
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 15 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100