how to backup sql database from c#2005
-
m working on the student management software on c#2005 and sql 2005 , i need to take backup of database " any session" from my application and also save it to the cd. i made differnt database for all session( for Example session07-08, session08-09) so if i want to take backup of sessiono7-08 from my c# application than
<>
-
m working on the student management software on c#2005 and sql 2005 , i need to take backup of database " any session" from my application and also save it to the cd. i made differnt database for all session( for Example session07-08, session08-09) so if i want to take backup of sessiono7-08 from my c# application than
<>
The below quick function will back up a database public void BackupDataBase(string databaseName,string Path) { string backUpQuery = "USE MASTER"+ "EXEC sp_addumpdevice 'disk', 'MyTestDatabase',"+ path+databaseName+".bak"+ "BACKUP DATABASE "+ databaseName +"TO MyTestDatabase"; SqlConnection con = new SqlConenction(connectionString); con.Open(); SqlCommand cmd=new SqlCommand(backUpQuery,con); cmd.ExecuteNonQuery(); } Please modify the same as required. laddie
-
The below quick function will back up a database public void BackupDataBase(string databaseName,string Path) { string backUpQuery = "USE MASTER"+ "EXEC sp_addumpdevice 'disk', 'MyTestDatabase',"+ path+databaseName+".bak"+ "BACKUP DATABASE "+ databaseName +"TO MyTestDatabase"; SqlConnection con = new SqlConenction(connectionString); con.Open(); SqlCommand cmd=new SqlCommand(backUpQuery,con); cmd.ExecuteNonQuery(); } Please modify the same as required. laddie
thanks but cud you plz tell waht i write instead of 'disk' and MyTestDatabase'
<>