Metoda Audit.Create
Tworzy wystąpienie programu audytu SQL Server określonych przez Audit obiektu.
Przestrzeń nazw: Microsoft.SqlServer.Management.Smo
Zestaw: Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)
Składnia
'Deklaracja
Public Sub Create
'Użycie
Dim instance As Audit
instance.Create()
public void Create()
public:
virtual void Create() sealed
abstract Create : unit -> unit
override Create : unit -> unit
public final function Create()
Implementacje
Uwagi
DestinationType i FilePath Właściwości inspekcji muszą być zdefiniowane przed utworzeniem audyt.
Przykłady
Poniższy przykład kodu tworzy nowy inspekcji z minimalną wymaganą liczbę zdefiniowanych właściwości.
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();
}
}
}
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()