Wednesday, May 11, 2011

Database backup command

create folder with name of  backup

SqlConnection con = new SqlConnection("Data Source=EASY-857AC062F0\\SQLEXPRESS;Initial Catalog=CAS;Integrated Security=True");
        SqlCommand cmd = new SqlCommand("backup database CAS to disk = '" + Server.MapPath("~/backup/CAS.bak") + "' ", con);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();

No comments :

Post a Comment