Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 13-Feb-13 5:34am
v2
Comments
priyanshbhaliya 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900