Click here to Skip to main content
12,759,096 members (33,022 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB 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
        End If

        Dim dbrest As New DatabaseUserAccess
        dbrest = DatabaseUserAccess.Single

        db = ((ComboBox1.SelectedItem)).ToString

        restore.Database = db
        Dim device As New BackupDeviceItem(Openbakfile.FileName, DeviceType.File)

        restore.Action = RestoreActionType.Database

        ProgressBar2.Value = 0
        restore.PercentCompleteNotification = 10
        restore.SqlRestore(sqlserver)// error here
        dbrest = DatabaseUserAccess.Multiple
    End Sub

i get error of restore fail for server and Affinity Info = {"Failed to retrieve data for this request
Posted 13-Feb-13 5:07am
Updated 13-Feb-13 6:34am
priyanshbhaliya 14-Feb-13 8:15am
Plz some one as fast.....

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2017
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