Share via


Audit Constructor (Server, String)

Initializes a new instance of the Server class on the specified instance of SQL Server and with the specified name.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

Syntax

'Declaration
Public Sub New ( _
    server As Server, _
    name As String _
)
'Usage
Dim server As Server 
Dim name As String 

Dim instance As New Audit(server, _
    name)
public Audit(
    Server server,
    string name
)
public:
Audit(
    Server^ server, 
    String^ name
)
new : 
        server:Server * 
        name:string -> Audit
public function Audit(
    server : Server, 
    name : String
)

Parameters

  • name
    Type: System.String
    A String object that specifies the name of the audit log to be created.

Examples

The following code example demonstrates how to create a new instance of the Audit class for the specified server and audit log name.

C#

using System;

using Microsoft.SqlServer.Management.Smo;

namespace samples

{

class Program

{

static void Main(string[] args)

{

Server dbServer = new Server("(local)");

Audit dbAudit = new Audit(dbServer, "Test Audit");

}

}

}

Powershell

$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbAudit = New-Object Microsoft.SqlServer.Management.Smo.Audit($dbServer, "Test Audit")

See Also

Reference

Audit Class

Audit Overload

Microsoft.SqlServer.Management.Smo Namespace