Metoda Server.EnumDetachedDatabaseFiles
Wylicza listę plików odłączoną bazę danych.
Przestrzeń nazw: Microsoft.SqlServer.Management.Smo
Zestaw: Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)
Składnia
'Deklaracja
Public Function EnumDetachedDatabaseFiles ( _
mdfName As String _
) As StringCollection
'Użycie
Dim instance As Server
Dim mdfName As String
Dim returnValue As StringCollection
returnValue = instance.EnumDetachedDatabaseFiles(mdfName)
public StringCollection EnumDetachedDatabaseFiles(
string mdfName
)
public:
StringCollection^ EnumDetachedDatabaseFiles(
String^ mdfName
)
member EnumDetachedDatabaseFiles :
mdfName:string -> StringCollection
public function EnumDetachedDatabaseFiles(
mdfName : String
) : StringCollection
Parametry
- mdfName
Typ: System.String
A String wartość, która określa nazwę pliku, który chcesz ograniczyć wyniki.
Wartość zwracana
Typ: System.Collections.Specialized.StringCollection
A StringCollection wartość obiektu system zawierający listę odłączony plik bazy danych nazwy.
Uwagi
Ta metoda służy do uzyskiwania nazw wszystkich odłączoną bazę danych (.mdf i.pliki ndf) na wystąpienie SQL Server.
Przykłady
C#
Server srv = new Server("(local)");
StringCollection sc = srv.EnumDetachedDatabaseFiles("C:\\Program Files\\Microsoft SQL Server\\MSSQL10_50.MSSQLSERVER\\MSSQL\\DATA\\DetachedDatabase.mdf");
foreach (String s in sc)
{
Console.WriteLine(s);
}
PowerShell
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$sc = $srv.EnumDetachedDatabaseFiles("C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DetachedDatabase.mdf")
Foreach ($s in $sc)
{
Write-Host $s
}
Zobacz także