Publication.StartSnapshotGenerationAgentJob 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
게시에 대한 초기 스냅샷을 생성하는 작업을 시작합니다.
public:
void StartSnapshotGenerationAgentJob();
public void StartSnapshotGenerationAgentJob ();
member this.StartSnapshotGenerationAgentJob : unit -> unit
Public Sub StartSnapshotGenerationAgentJob ()
예외
서버에서 Microsoft SQL Server 2005 이상을 실행하고 있지 않거나 게시가 서버에 없습니다.
예제
// Set the Publisher, publication database, and publication names.
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";
string publisherName = publisherInstance;
TransPublication publication;
// Create a connection to the Publisher using Windows Authentication.
ServerConnection conn;
conn = new ServerConnection(publisherName);
try
{
// Connect to the Publisher.
conn.Connect();
// Set the required properties for an existing publication.
publication = new TransPublication();
publication.ConnectionContext = conn;
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
if (publication.LoadProperties())
{
// Start the Snapshot Agent job for the publication.
publication.StartSnapshotGenerationAgentJob();
}
else
{
throw new ApplicationException(String.Format(
"The {0} publication does not exist.", publicationName));
}
}
catch (Exception ex)
{
// Implement custom application error handling here.
throw new ApplicationException(String.Format(
"A snapshot could not be generated for the {0} publication."
, publicationName), ex);
}
finally
{
conn.Disconnect();
}
' Set the Publisher, publication database, and publication names.
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim publisherName As String = publisherInstance
Dim publication As TransPublication
' Create a connection to the Publisher using Windows Authentication.
Dim conn As ServerConnection
conn = New ServerConnection(publisherName)
Try
' Connect to the Publisher.
conn.Connect()
' Set the required properties for an existing publication.
publication = New TransPublication()
publication.ConnectionContext = conn
publication.Name = publicationName
publication.DatabaseName = publicationDbName
If publication.LoadProperties() Then
' Start the Snapshot Agent job for the publication.
publication.StartSnapshotGenerationAgentJob()
Else
Throw New ApplicationException(String.Format( _
"The {0} publication does not exist.", publicationName))
End If
Catch ex As Exception
' Implement custom application error handling here.
Throw New ApplicationException(String.Format( _
"A snapshot could not be generated for the {0} publication." _
, publicationName), ex)
Finally
conn.Disconnect()
End Try
설명
메서드는 StartSnapshotGenerationAgentJob 게시자에서 고정 서버 역할의 sysadmin
멤버 또는 게시 데이터베이스의 db_owner
고정 데이터베이스 역할 멤버에 의해서만 호출할 수 있습니다.
호출 StartSnapshotGenerationAgentJob 은 sp_startpublication_snapshot(Transact-SQL)을 실행하는 것과 같습니다.