Udostępnij za pośrednictwem


Metoda AttachDatabase (String, StringCollection, AttachOptions)

Dołącza bazy danych, który składa się z jednego lub więcej plików do wystąpienie SQL Server ma określoną nazwą i korzystanie z plików określonych danych i opcje załącznika.

Przestrzeń nazw:  Microsoft.SqlServer.Management.Smo
Zestaw:  Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)

Syntax

'Deklaracja
Public Sub AttachDatabase ( _
    name As String, _
    files As StringCollection, _
    attachOptions As AttachOptions _
)
'Użycie
Dim instance As Server
Dim name As String
Dim files As StringCollection
Dim attachOptions As AttachOptions

instance.AttachDatabase(name, files, attachOptions)
public void AttachDatabase(
    string name,
    StringCollection files,
    AttachOptions attachOptions
)
public:
void AttachDatabase(
    String^ name, 
    StringCollection^ files, 
    AttachOptions attachOptions
)
member AttachDatabase : 
        name:string * 
        files:StringCollection * 
        attachOptions:AttachOptions -> unit 
public function AttachDatabase(
    name : String, 
    files : StringCollection, 
    attachOptions : AttachOptions
)

Parameters

Uwagi

Pliki dziennika transakcji i danych bazy danych może być odłączone i następnie ponownie przymocowana do tej samej lub innej wystąpienie z SQL Server.Odłączania i dołączania bazy danych jest przydatna, jeśli chcesz zmienić bazę danych do innego wystąpienie SQL Server na tym samym komputerze lub jeśli chcesz przenieść bazy danych.