SqlRowUpdatingEventArgs 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
RowUpdating 이벤트에 대한 데이터를 제공합니다.
public ref class SqlRowUpdatingEventArgs sealed : System::Data::Common::RowUpdatingEventArgs
public sealed class SqlRowUpdatingEventArgs : System.Data.Common.RowUpdatingEventArgs
type SqlRowUpdatingEventArgs = class
inherit RowUpdatingEventArgs
Public NotInheritable Class SqlRowUpdatingEventArgs
Inherits RowUpdatingEventArgs
- 상속
예제
다음 예제에서는 이벤트와 RowUpdating 이벤트를 모두 RowUpdated 사용하는 방법을 보여 줍니다.
이 이벤트는 다음 RowUpdating 출력을 반환합니다.
이벤트 인수: (command=System.Data.SqlClient.SQLCommand commandType=2 status=0)
이 이벤트는 다음 RowUpdated 출력을 반환합니다.
이벤트 인수: (command=System.Data.SqlClient.SQLCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)
// handler for RowUpdating event
private static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e)
{
PrintEventArgs(e);
}
//Handler for RowUpdated event.
private static void OnRowUpdated(object sender, SqlRowUpdatedEventArgs e)
{
PrintEventArgs(e);
}
public static int Main()
{
const string CONNECTION_STRING = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer";
const string SELECT_ALL = "select * from Products";
//Create DataAdapter.
SqlDataAdapter rAdapter = new SqlDataAdapter(SELECT_ALL, CONNECTION_STRING);
//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] = "new product";
//Add handlers.
rAdapter.RowUpdating += new SqlRowUpdatingEventHandler( OnRowUpdating );
rAdapter.RowUpdated += new SqlRowUpdatedEventHandler( OnRowUpdated );
//Update--this operation fires two events (RowUpdating and RowUpdated) for each changed row.
rAdapter.Update(rDataSet, "Table");
//Remove handlers.
rAdapter.RowUpdating -= new SqlRowUpdatingEventHandler( OnRowUpdating );
rAdapter.RowUpdated -= new SqlRowUpdatedEventHandler( OnRowUpdated );
return 0;
}
private static void PrintEventArgs(SqlRowUpdatingEventArgs args)
{
Console.WriteLine("OnRowUpdating");
Console.WriteLine(" event args: ("+
" command=" + args.Command +
" commandType=" + args.StatementType +
" status=" + args.Status + ")");
}
private static void PrintEventArgs(SqlRowUpdatedEventArgs 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 SqlRowUpdatingEventArgs)
PrintEventArgs(e)
End Sub
'Handler for RowUpdated event.
Private Shared Sub OnRowUpdated(sender As Object, e As SqlRowUpdatedEventArgs)
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 = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer"
Const SELECT_ALL As String = "select * from Products"
'Create DataAdapter.
Dim rAdapter As New SqlDataAdapter(SELECT_ALL, CONNECTION_STRING)
'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) = "new product"
'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
Overloads Private Shared Sub PrintEventArgs(args As SqlRowUpdatingEventArgs)
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 SqlRowUpdatedEventArgs)
Console.WriteLine("OnRowUpdated")
Console.WriteLine(" event args: (" & _
" command=" & _
args.Command.CommandText & _
" commandType=" & _
args.StatementType & _
" recordsAffected=" & _
args.RecordsAffected & _
" status=" & _
args.Status & _
")")
End Sub
설명
이벤트는 RowUpdating 행 앞에 Update 발생합니다.
사용하는 Update경우 업데이트된 각 데이터 행에 대해 두 개의 이벤트가 발생합니다. 실행 순서는 다음과 같습니다.
해당 값은 DataRow 매개 변수 값으로 이동됩니다.
OnRowUpdating 이벤트가 발생합니다.
명령이 실행됩니다.
명령을 로
FirstReturnedRecord설정하고 반환된 첫 번째 결과가 에 DataRow배치되는 경우출력 매개 변수 DataRow가 있는 경우 .
OnRowUpdated 이벤트가 발생합니다.
AcceptChanges을 호출합니다.
생성자
| Name | Description |
|---|---|
| SqlRowUpdatingEventArgs(DataRow, IDbCommand, StatementType, DataTableMapping) |
SqlRowUpdatingEventArgs 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| BaseCommand |
이 클래스의 IDbCommand 인스턴스에 대한 개체를 가져오거나 설정합니다. (다음에서 상속됨 RowUpdatingEventArgs) |
| Command |
를 수행할 Update(DataSet)때 실행할 값을 가져오거나 설정합니다SqlCommand. |
| Errors |
Command 실행될 때 .NET 데이터 공급자가 생성한 오류를 가져옵니다. (다음에서 상속됨 RowUpdatingEventArgs) |
| Row |
DataRow 삽입, 업데이트 또는 삭제 작업의 일부로 서버에 전송되는 항목을 가져옵니다. (다음에서 상속됨 RowUpdatingEventArgs) |
| StatementType |
실행할 SQL 문의 형식을 가져옵니다. (다음에서 상속됨 RowUpdatingEventArgs) |
| Status |
속성의 Command 값을 UpdateStatus 가져오거나 설정합니다. (다음에서 상속됨 RowUpdatingEventArgs) |
| TableMapping |
를 DataTableMapping 통해 보낼 값을 가져옵니다 Update(DataSet). (다음에서 상속됨 RowUpdatingEventArgs) |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |