Proprietà ID
Gets the integer value that uniquely identifies the audit.
Spazio dei nomi Microsoft.SqlServer.Management.Smo
Assembly: Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)
Sintassi
'Dichiarazione
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public ReadOnly Property ID As Integer
Get
'Utilizzo
Dim instance As Audit
Dim value As Integer
value = instance.ID
[SfcPropertyAttribute(SfcPropertyFlags.Standalone)]
public int ID { get; }
[SfcPropertyAttribute(SfcPropertyFlags::Standalone)]
public:
property int ID {
int get ();
}
[<SfcPropertyAttribute(SfcPropertyFlags.Standalone)>]
member ID : int
function get ID () : int
Valore proprietà
Tipo: System. . :: . .Int32
A Integer value that uniquely identifies the audit.
Esempi
The following code example demonstrates how to get the unique ID of the audit 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();
//Get the ID
Console.WriteLine("The ID of the audit log file is: " +
dbAudit.ID);
}
}
}
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()
#Get and display the ID
Write-Host "The ID of the audit log file is:" $dbAudit.ID