Поделиться через


Свойство Audit.Parent

Gets the Server object that is the parent of the Audit object.

Пространство имен:  Microsoft.SqlServer.Management.Smo
Сборка:  Microsoft.SqlServer.Smo (в Microsoft.SqlServer.Smo.dll)

Синтаксис

'Декларация
<SfcObjectAttribute(SfcObjectRelationship.ParentObject)> _
Public Property Parent As Server 
    Get 
    Set
'Применение
Dim instance As Audit 
Dim value As Server 

value = instance.Parent

instance.Parent = value
[SfcObjectAttribute(SfcObjectRelationship.ParentObject)]
public Server Parent { get; set; }
[SfcObjectAttribute(SfcObjectRelationship::ParentObject)]
public:
property Server^ Parent {
    Server^ get ();
    void set (Server^ value);
}
[<SfcObjectAttribute(SfcObjectRelationship.ParentObject)>]
member Parent : Server with get, set
function get Parent () : Server 
function set Parent (value : Server)

Значение свойства

Тип: Microsoft.SqlServer.Management.Smo.Server
A Server object that is the parent of the Audit object.

Замечания

The parent of the Audit object is the instance of SQL Server on which the audit is defined.

Примеры

The following code example demonstrates how to get the name of the parent server and display it on the console.

C#

using System;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create the audit
            Server dbServer = new Server("(local)");
            Audit dbAudit = new Audit(dbServer, "Test Audit");
            dbAudit.DestinationType = AuditDestinationType.File;
            dbAudit.FilePath = "C:\\AuditDirectory";
            dbAudit.Create();
             
            //Display the name of the parent server on the console
            Console.WriteLine(dbAudit.Parent.Name);
        }
    }
}

Powershell

#Create the audit 
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbAudit = New-Object Microsoft.SqlServer.Management.Smo.Audit($dbServer, "Test Audit")
$dbAudit.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]'File'
$dbAudit.FilePath = "C:\AuditDirectory"
$dbAudit.Create()

#Display the name of the parent server on the console
Write-Host $dbAudit.Parent.Name

См. также

Справочник

Audit Класс

Пространство имен Microsoft.SqlServer.Management.Smo