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. {"Restore failed for Server '\\\\.\\pipe\\3F103E6E-3FD4-47\\tsql\\query'. "}

{"Restore failed for Server '\\\\.\\pipe\\3F103E6E-3FD4-47\\tsql\\query'. "}

Scheduled Pinned Locked Moved C#
databasecsharpsql-serversysadmintutorial
1 Posts 1 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.
  • M Offline
    M Offline
    Mohammad Dayyan
    wrote on last edited by
    #1

    Hi guys, I'm using the following code to restore a backup sql database with C# and SMO.

    void RestoreDatabaseWithSMO(string sConnect, string dbName, string backUpPath)
    {
    using (SqlConnection cnn = new SqlConnection(sConnect))
    {
    cnn.Open();
    cnn.ChangeDatabase("master");

        ServerConnection sc = new ServerConnection(cnn);
        Server sv = new Server(sc);
    
        if (!sv.Databases.Contains(dbName))
            throw new Exception("this DataBase does not exist");
    
        // Create backup device item for the backup
        BackupDeviceItem bdi = new BackupDeviceItem(backUpPath, DeviceType.File);
    
        // Create the restore object
        Restore resDB = new Restore();
        resDB.PercentComplete += new PercentCompleteEventHandler(percentComplete);
        resDB.PercentCompleteNotification = 10;
        resDB.Devices.Add(bdi);
        resDB.NoRecovery = false;
        resDB.ReplaceDatabase = true;
        resDB.Database = dbName;
        resDB.Action = RestoreActionType.Database;
    
        // Restore the database
        resDB.SqlRestore(sv);//Exception
    }
    

    }

    but in the last line I got below exception !!!

    {"Restore failed for Server '\\\\.\\pipe\\3F103E6E-3FD4-47\\tsql\\query'. "}

    What's wrong with it ? Could you please guide me? Thanks

    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