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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to restore Backup file from remote PC to SQL Server?

How to restore Backup file from remote PC to SQL Server?

Scheduled Pinned Locked Moved C#
databasesysadminsql-serverhelptutorial
2 Posts 2 Posters 1 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.
  • S Offline
    S Offline
    Sachin Gedam
    wrote on last edited by
    #1

    Hello Friedns, I am tring to restore backup file which is on Machine1. And SQL server might be on anyother machine in local network. I am using this Code: ============================================================== //create an instance of a server class SQLDMO._SQLServer srv = new SQLDMO.SQLServerClass(); //connect to the server if(rbLocal.Checked==true) srv.Connect(this.txtServName.Text,this.txtUserName.Text,this.txtPass.Text); else srv.Connect(this.cmbServList.Text,this.txtUserName.Text,this.txtPass.Text); //create a restore class instance SQLDMO.Restore res = new SQLDMO.RestoreClass(); //set the backup device = files property ( easy way ) res.Devices = res.Files; //set the files property to the File Name text box res.Files = "[" + System.IO.Path.GetTempPath()+"AlcoMateBlank.BAK" + "]"; //set the database to the chosen database res.Database = this.txtDBName.Text; // Restore the database res.ReplaceDatabase = true; res.SQLRestore(srv); ============================================================== This code working properly if Backup file is on Local Machine but not if backup file is on another machine in a network. I am getting this error BackupDiskFile::OpenMedia: Backup device 'C:\DOCUME~1\sachin\LOCALS~1\Temp\AlcoMateBlank.BAK' failed to open. Operating system error = 3(The system cannot find the path specified.). Can you please suggest me eassy way of restoring database from remote PC to remote sql server which is in LAN? Sachin Gedam (Software Engg.) Pune India

    D 1 Reply Last reply
    0
    • S Sachin Gedam

      Hello Friedns, I am tring to restore backup file which is on Machine1. And SQL server might be on anyother machine in local network. I am using this Code: ============================================================== //create an instance of a server class SQLDMO._SQLServer srv = new SQLDMO.SQLServerClass(); //connect to the server if(rbLocal.Checked==true) srv.Connect(this.txtServName.Text,this.txtUserName.Text,this.txtPass.Text); else srv.Connect(this.cmbServList.Text,this.txtUserName.Text,this.txtPass.Text); //create a restore class instance SQLDMO.Restore res = new SQLDMO.RestoreClass(); //set the backup device = files property ( easy way ) res.Devices = res.Files; //set the files property to the File Name text box res.Files = "[" + System.IO.Path.GetTempPath()+"AlcoMateBlank.BAK" + "]"; //set the database to the chosen database res.Database = this.txtDBName.Text; // Restore the database res.ReplaceDatabase = true; res.SQLRestore(srv); ============================================================== This code working properly if Backup file is on Local Machine but not if backup file is on another machine in a network. I am getting this error BackupDiskFile::OpenMedia: Backup device 'C:\DOCUME~1\sachin\LOCALS~1\Temp\AlcoMateBlank.BAK' failed to open. Operating system error = 3(The system cannot find the path specified.). Can you please suggest me eassy way of restoring database from remote PC to remote sql server which is in LAN? Sachin Gedam (Software Engg.) Pune India

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Copy the file to the SQL Server machine first. Then tell the SQL Server where to find the file on it's own hard drive. The problem with telling SQL Server where to find the file on a remote machine is that the account that is used to do the acctual restore most likely will not have permissions to the remote machine where the backup file is stored. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      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