OracleRowUpdatedEventArgs 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供 RowUpdated 事件的資料。 此類別無法獲得繼承。
public ref class OracleRowUpdatedEventArgs sealed : System::Data::Common::RowUpdatedEventArgs
public sealed class OracleRowUpdatedEventArgs : System.Data.Common.RowUpdatedEventArgs
type OracleRowUpdatedEventArgs = class
inherit RowUpdatedEventArgs
Public NotInheritable Class OracleRowUpdatedEventArgs
Inherits RowUpdatedEventArgs
- 繼承
範例
下列範例示範如何使用 RowUpdating 和 RowUpdated 事件。
事件會 RowUpdating 傳回此輸出:
Event Arguments: (command=OracleCommand commandType=2status=0)
事件會 RowUpdated 傳回此輸出:
Event Arguments: (command= OracleCommend commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)
// handler for RowUpdating event
private static void OnRowUpdating(object sender, OracleRowUpdatingEventArgs e) {
PrintEventArgs(e);
}
//Handler for RowUpdated event.
private static void OnRowUpdated(object sender, OracleRowUpdatedEventArgs e) {
PrintEventArgs(e);
}
public static int Main(String[] args) {
const string CONNECTION_STRING = "Data Source=Oracle8i;Integrated Security=yes";
const string SELECT_ALL = "SELECT * FROM Scott.Emp";
//Create DataAdapter.
OracleDataAdapter rAdapter = new OracleDataAdapter(SELECT_ALL, CONNECTION_STRING);
OracleCommandBuilder cb = new OracleCommandBuilder(rAdapter);
//Create and fill DataSet (Select only first 5 rows.).
DataSet rDataSet = new DataSet();
rAdapter.Fill(rDataSet, 0, 5, "Table");
//Modify DataSet.
DataTable rTable = rDataSet.Tables["Table"];
rTable.Rows[0][1] = "DYZY";
//Add handlers.
rAdapter.RowUpdating += new OracleRowUpdatingEventHandler( OnRowUpdating );
rAdapter.RowUpdated += new OracleRowUpdatedEventHandler( OnRowUpdated );
//Update--this operation fires two events (RowUpdating and RowUpdated) for each changed row.
rAdapter.Update(rDataSet, "Table");
//Remove handlers.
rAdapter.RowUpdating -= new OracleRowUpdatingEventHandler( OnRowUpdating );
rAdapter.RowUpdated -= new OracleRowUpdatedEventHandler( OnRowUpdated );
return 0;
}
private static void PrintEventArgs(OracleRowUpdatingEventArgs args) {
Console.WriteLine("OnRowUpdating");
Console.WriteLine(" event args: ("+
" command=" + args.Command +
" commandType=" + args.StatementType +
" status=" + args.Status + ")");
}
private static void PrintEventArgs(OracleRowUpdatedEventArgs args) {
Console.WriteLine("OnRowUpdated");
Console.WriteLine( " event args: ("+
" command=" + args.Command +
" commandType=" + args.StatementType +
" recordsAffected=" + args.RecordsAffected +
" status=" + args.Status + ")" );
}
'Handler for RowUpdating event.
Private Shared Sub OnRowUpdating(sender As Object, e As OracleRowUpdatingEventArgs)
PrintEventArgs(e)
End Sub
'Handler for RowUpdated event.
Private Shared Sub OnRowUpdated(sender As Object, e As OracleRowUpdatedEventArgs)
PrintEventArgs(e)
End Sub
'Entry point which delegates to C-style main Private Function.
Public Overloads Shared Sub Main()
System.Environment.ExitCode = Main(System.Environment.GetCommandLineArgs())
End Sub
Overloads Public Shared Function Main(args() As String) As Integer
Const CONNECTION_STRING As String = "Data Source=Oracle8i;Integrated Security=yes"
Const SELECT_ALL As String = "SELECT * FROM Scott.Emp"
'Create DataAdapter.
Dim rAdapter As New OracleDataAdapter(SELECT_ALL, CONNECTION_STRING)
Dim cb As New OracleCommandBuilder(rAdapter)
'Create and fill DataSet (Select only first 5 rows.).
Dim rDataSet As New DataSet()
rAdapter.Fill(rDataSet, 0, 5, "Table")
'Modify DataSet.
Dim rTable As DataTable = rDataSet.Tables("Table")
rTable.Rows(0)(1) = "DYZY"
'Add handlers.
AddHandler rAdapter.RowUpdating, AddressOf OnRowUpdating
AddHandler rAdapter.RowUpdated, AddressOf OnRowUpdated
'Update--this operation fires two events (RowUpdating and RowUpdated) for each changed row.
rAdapter.Update(rDataSet, "Table")
'Remove handlers.
RemoveHandler rAdapter.RowUpdating, AddressOf OnRowUpdating
RemoveHandler rAdapter.RowUpdated, AddressOf OnRowUpdated
Return 0
End Function 'Main
Overloads Private Shared Sub PrintEventArgs(args As OracleRowUpdatingEventArgs)
Console.WriteLine("OnRowUpdating")
Console.WriteLine(" event args: (" & " command=" & args.Command.CommandText & _
" commandType=" & args.StatementType & " status=" & args.Status & ")")
End Sub
Overloads Private Shared Sub PrintEventArgs(args As OracleRowUpdatedEventArgs)
Console.WriteLine("OnRowUpdated")
Console.WriteLine(" event args: (" & " command=" & args.Command.CommandText & _
" commandType=" & args.StatementType & " recordsAffected=" & _
args.RecordsAffected & " status=" & args.Status & ")")
End Sub
End Class
備註
當數據列完成時Update,就會RowUpdated引發 事件。
使用 Update時,每個數據列都會更新兩個事件。 執行順序如下:
中的 DataRow 值會移至參數值。
便會引發 OnRowUpdating 事件。
命令會執行。
如果命令設定為
FirstReturnedRecord
,則會將 DataRow第一個傳回的結果放在 中。如果有輸出參數,它們會放在 中 DataRow。
便會引發 OnRowUpdated 事件。
呼叫 AcceptChanges。
建構函式
OracleRowUpdatedEventArgs(DataRow, IDbCommand, StatementType, DataTableMapping) |
初始化 OracleRowUpdatedEventArgs 類別的新執行個體。 |
屬性
Command |
取得或設定當呼叫 OracleCommand 時執行的 Update(DataSet)。 |
Errors |
取得執行 Command 時由 .NET 資料提供者產生的任何錯誤。 (繼承來源 RowUpdatedEventArgs) |
RecordsAffected |
取得因執行 SQL 陳述式所變更、插入或刪除的資料列數目。 (繼承來源 RowUpdatedEventArgs) |
Row |
取得經由 DataRow 所傳送的 Update(DataSet)。 (繼承來源 RowUpdatedEventArgs) |
RowCount |
取得在已更新記錄的批次中處理的列數。 (繼承來源 RowUpdatedEventArgs) |
StatementType |
取得已執行的 SQL 陳述式型別。 (繼承來源 RowUpdatedEventArgs) |
Status |
取得 UpdateStatus 的 Command。 (繼承來源 RowUpdatedEventArgs) |
TableMapping |
取得經由 DataTableMapping 所傳送的 Update(DataSet)。 (繼承來源 RowUpdatedEventArgs) |
方法
CopyToRows(DataRow[], Int32) |
複製已修改之列的參考至所提供的陣列中。 (繼承來源 RowUpdatedEventArgs) |
CopyToRows(DataRow[]) |
複製已修改之列的參考至所提供的陣列中。 (繼承來源 RowUpdatedEventArgs) |
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
ToString() |
傳回代表目前物件的字串。 (繼承來源 Object) |