title: how to restore using restore class of Microsoft.SqlServer.Management.Smo namespace
body: <pre><code>public void  RestoreDatabase(String databaseName, String filePath, 
              String serverName, String userName, String password, String dataFilePath, String logFilePath)
  {
      Restore sqlRestore = new Restore();
      BackupDeviceItem deviceItem = new BackupDeviceItem(filePath, DeviceType.File);
      sqlRestore.Devices.Add(deviceItem);
      sqlRestore.Database = databaseName;
      ServerConnection connection = new ServerConnection(serverName, userName, password);
      Server sqlServer = new Server(connection);
      Database db = sqlServer.Databases[databaseName];
      sqlRestore.Action = RestoreActionType.Database;
      String dataFileLocation = dataFilePath;
      String logFileLocation = logFilePath; 
      db = sqlServer.Databases[databaseName];
      sqlRestore.RelocateFiles.Add(new RelocateFile(databaseName, dataFileLocation));
      sqlRestore.RelocateFiles.Add(new RelocateFile(databaseName + "_log", logFileLocation));
      sqlRestore.ReplaceDatabase = true;
      sqlRestore.Complete +=new ServerMessageEventHandler(sqlRestore_Complete);
      sqlRestore.SqlRestore(sqlServer);
      db = sqlServer.Databases[databaseName];
      db.SetOnline();
      sqlServer.Refresh();
  }
  </code></pre>
  
  <p>On calling this method the restore operation failed with this message</p>
  
  <blockquote>
    <p>Restore failed for Server
    'MDM04\SQLEXPRESS'.</p>
  </blockquote>
  
  <p>mdm04 is my computer name</p>
  
  <p>the inner exception is</p>
  
  <blockquote>
    <p>"System.Data.SqlClient.SqlError:
    Logical file 'vrv' is not part of
    database 'vrv'. Use RESTORE
    FILELISTONLY to list the logical file
    names."</p>
  </blockquote>
  
  <p>vrv is database name</p>
  
  <p>What should I do to restore the file</p>