Udostępnij za pośrednictwem


Metoda Audit.Enable

Umożliwia audytu.

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

Składnia

'Deklaracja
Public Sub Enable
'Użycie
Dim instance As Audit

instance.Enable()
public void Enable()
public:
void Enable()
member Enable : unit -> unit 
public function Enable()

Przykłady

Poniższy przykład kodu pokazuje włączania inspekcji po jego utworzeniu.

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();

            //Enable the audit
            dbAudit.Enable();
        }
    }
}

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()

#Enable the audit
$dbAudit.Enable()