CommittableTransaction 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
CommittableTransaction 클래스의 새 인스턴스를 초기화합니다.
오버로드
CommittableTransaction() |
CommittableTransaction 클래스의 새 인스턴스를 초기화합니다. |
CommittableTransaction(TimeSpan) |
지정된 CommittableTransaction 값을 사용하여 |
CommittableTransaction(TransactionOptions) |
지정된 트랜잭션 옵션을 사용하여 CommittableTransaction 클래스의 새 인스턴스를 초기화합니다. |
CommittableTransaction()
- Source:
- CommittableTransaction.cs
- Source:
- CommittableTransaction.cs
- Source:
- CommittableTransaction.cs
CommittableTransaction 클래스의 새 인스턴스를 초기화합니다.
public:
CommittableTransaction();
public CommittableTransaction ();
Public Sub New ()
예제
다음 샘플에서는 의 CommittableTransaction 새 인스턴스를 만들고 커밋합니다.
//Create a committable transaction
tx = new CommittableTransaction();
SqlConnection myConnection = new SqlConnection("server=(local)\\SQLExpress;Integrated Security=SSPI;database=northwind");
SqlCommand myCommand = new SqlCommand();
//Open the SQL connection
myConnection.Open();
//Give the transaction to SQL to enlist with
myConnection.EnlistTransaction(tx);
myCommand.Connection = myConnection;
// Restore database to near it's original condition so sample will work correctly.
myCommand.CommandText = "DELETE FROM Region WHERE (RegionID = 100) OR (RegionID = 101)";
myCommand.ExecuteNonQuery();
// Insert the first record.
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'MidWestern')";
myCommand.ExecuteNonQuery();
// Insert the second record.
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'MidEastern')";
myCommand.ExecuteNonQuery();
// Commit or rollback the transaction
while (true)
{
Console.Write("Commit or Rollback? [C|R] ");
ConsoleKeyInfo c = Console.ReadKey();
Console.WriteLine();
if ((c.KeyChar == 'C') || (c.KeyChar == 'c'))
{
tx.Commit();
break;
}
else if ((c.KeyChar == 'R') || (c.KeyChar == 'r'))
{
tx.Rollback();
break;
}
}
myConnection.Close();
tx = null;
tx = New CommittableTransaction
Dim myConnection As New SqlConnection("server=(local)\SQLExpress;Integrated Security=SSPI;database=northwind")
Dim myCommand As New SqlCommand()
'Open the SQL connection
myConnection.Open()
'Give the transaction to SQL to enlist with
myConnection.EnlistTransaction(tx)
myCommand.Connection = myConnection
'Restore database to near it's original condition so sample will work correctly.
myCommand.CommandText = "DELETE FROM Region WHERE (RegionID = 100) OR (RegionID = 101)"
myCommand.ExecuteNonQuery()
'Insert the first record.
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'MidWestern')"
myCommand.ExecuteNonQuery()
'Insert the second record.
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'MidEastern')"
myCommand.ExecuteNonQuery()
'Commit or rollback the transaction
Dim c As ConsoleKeyInfo
While (True)
Console.Write("Commit or Rollback? [C|R] ")
c = Console.ReadKey()
Console.WriteLine()
If (c.KeyChar = "C") Or (c.KeyChar = "c") Then
tx.Commit()
Exit While
ElseIf ((c.KeyChar = "R") Or (c.KeyChar = "r")) Then
tx.Rollback()
Exit While
End If
End While
myConnection.Close()
tx = Nothing
적용 대상
CommittableTransaction(TimeSpan)
- Source:
- CommittableTransaction.cs
- Source:
- CommittableTransaction.cs
- Source:
- CommittableTransaction.cs
지정된 CommittableTransaction 값을 사용하여 timeout
클래스의 새 인스턴스를 초기화합니다.
public:
CommittableTransaction(TimeSpan timeout);
public CommittableTransaction (TimeSpan timeout);
new System.Transactions.CommittableTransaction : TimeSpan -> System.Transactions.CommittableTransaction
Public Sub New (timeout As TimeSpan)
매개 변수
- timeout
- TimeSpan
트랜잭션이 중단되기 전에 존재할 수 있는 최대 시간입니다.
적용 대상
CommittableTransaction(TransactionOptions)
- Source:
- CommittableTransaction.cs
- Source:
- CommittableTransaction.cs
- Source:
- CommittableTransaction.cs
지정된 트랜잭션 옵션을 사용하여 CommittableTransaction 클래스의 새 인스턴스를 초기화합니다.
public:
CommittableTransaction(System::Transactions::TransactionOptions options);
public CommittableTransaction (System.Transactions.TransactionOptions options);
new System.Transactions.CommittableTransaction : System.Transactions.TransactionOptions -> System.Transactions.CommittableTransaction
Public Sub New (options As TransactionOptions)
매개 변수
- options
- TransactionOptions
새 트랜잭션에 사용할 트랜잭션 옵션을 설명하는 TransactionOptions 구조체입니다.
예외
options
이 잘못되었습니다.
예제
다음 샘플에서는 옵션을 사용하여 의 CommittableTransaction 새 인스턴스를 만들고 중단합니다.
적용 대상
.NET