Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to backup sql database from c#2005

how to backup sql database from c#2005

Scheduled Pinned Locked Moved C#
databasetutorialcsharp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tech progg
    wrote on last edited by
    #1

    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

    <>

    L 1 Reply Last reply
    0
    • T tech progg

      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

      <>

      L Offline
      L Offline
      laddie 0
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • L laddie 0

        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

        T Offline
        T Offline
        tech progg
        wrote on last edited by
        #3

        thanks but cud you plz tell waht i write instead of 'disk' and MyTestDatabase'

        <>

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups