Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Please help! I tried but cannot solve.
 
Here is the code I use is following:
Imports System.Data.SqlClient
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management
Imports Microsoft.SqlServer.Management.Common
Imports Microsoft.SqlServer.Management.Sdk.Sfc
Imports System.Configuration
 
Dim db As String = ""
    Dim dbname As String = ""
    Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\LandandBuildingProject\LandandBuildingProject\Building.mdf;Integrated Security=True;User Instance=True")
    Dim sqlserver As New Server(New ServerConnection(con))
    Dim WithEvents backup As New Backup
    Dim WithEvents restore As New Restore
    
    Sub dbrestore()
         If con.State = ConnectionState.Closed Then
            con.Open()
        End If
 
        Dim dbrest As New DatabaseUserAccess
        dbrest = DatabaseUserAccess.Single
        sqlserver.KillAllProcesses(db)
 

        db = ((ComboBox1.SelectedItem)).ToString
 
        restore.Database = db
 
        Dim device As New BackupDeviceItem(Openbakfile.FileName, DeviceType.File)
        restore.Devices.Add(device)
 
        restore.Action = RestoreActionType.Database
 
        ProgressBar2.Value = 0
        restore.PercentCompleteNotification = 10
        restore.SqlRestore(sqlserver)// error here
        con.Close()
        dbrest = DatabaseUserAccess.Multiple
        restore.Devices.Clear()
        
    End Sub
i get error of restore fail for server and Affinity Info = {"Failed to retrieve data for this request
thanks....
Posted 13-Feb-13 5:07am
Edited 13-Feb-13 6:34am
v2
Comments
priyanshbhaliya at 14-Feb-13 8:15am
   
Plz some one Help.......fast as fast.....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 285
1 DamithSL 265
2 CPallini 195
3 Maciej Los 175
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100