EnumTransactions 方法
列舉資料庫中開啟交易的清單。
命名空間: Microsoft.SqlServer.Management.Smo
組件: Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)
語法
'宣告
Public Function EnumTransactions As DataTable
'用途
Dim instance As Database
Dim returnValue As DataTable
returnValue = instance.EnumTransactions()
public DataTable EnumTransactions()
public:
DataTable^ EnumTransactions()
member EnumTransactions : unit -> DataTable
public function EnumTransactions() : DataTable
傳回值
型別:System.Data. . :: . .DataTable
包含影響資料庫之開啟交易清單的 DataTable 物件值。此表將描述傳回之 DataTable 的不同資料行。
資料行 |
資料類型 |
描述 |
---|---|---|
名稱 |
交易的名稱。 |
|
TransactionID |
可唯一識別交易的識別碼值。請參閱<sys.dm_tran_active_transactions (Transact-SQL)>。 |
|
BeginTime |
交易的開始日期和時間。 |
|
Spid |
可唯一識別執行交易所在之工作階段的工作階段識別碼。 |
|
DatabaseName |
執行交易所在之資料庫的名稱。 |
|
DatabaseID |
執行交易所在之資料庫的識別碼值。 |
|
DatabaseBeginTime |
資料庫上線的日期和時間。 |
|
IsVersioned |
指定交易是否為快照集交易且具有序號的布林值。請參閱 TransactionTypes 列舉類別。 |
範例
The example runs a Server object enumeration method, but extracting the information from the DataTable object is the same for Database enumeration methods.
VB
'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Call the EnumCollations method and return collation information to DataTable variable.
Dim d As DataTable
'Select the returned data into an array of DataRow.
d = srv.EnumCollations
'Iterate through the rows and display collation details for the instance of SQL Server.
Dim r As DataRow
Dim c As DataColumn
For Each r In d.Rows
Console.WriteLine("============================================")
For Each c In r.Table.Columns
Console.WriteLine(c.ColumnName + " = " + r(c).ToString)
Next
Next
PowerShell
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$d = new-object System.Data.Datatable
$d = $srv.EnumCollations
Foreach ($r in $d.Rows)
{
Write-Host "============================================"
Foreach ($c in $d.Columns)
{
Write-Host $c.ColumnName "=" $r[$c]
}
}