SqlDataSourceStatusEventArgs クラス
アセンブリ: System.Web (system.web.dll 内)


SqlDataSourceStatusEventArgs クラスは、データ ソース コントロールによって実行されたデータベース操作の完了後、Selected、Updated、Inserted、Deleted の各イベントで、これらの操作に関する情報を渡すために使用されます。この情報には、操作によって影響を受けた行数、データ ソースが操作を実行するために使用した DbCommand オブジェクト、発生した例外情報などが含まれます。Selected、Updated、Inserted、Deleted の各イベントを処理するためのイベント ハンドラ デリゲートを追加することで、このデータをチェックして、必要な追加のポスト プロセスを実行できます。
SqlDataSource コントロールは、データ操作の過程で、基になるデータ オブジェクトを操作する際に利用できる、数多くのイベントを公開しています。次の表は、SqlDataSource コントロールを使用したデータ操作の一連の流れに対応するさまざまなイベントをわかりやすく紹介するために、各種のイベントと、個々のイベントに対応する EventArgs、およびイベント ハンドラ クラスをまとめたものです。
SqlDataSourceSelectingEventArgs | SqlDataSourceSelectingEventHandler | |
Inserting、Updating、および、Deleting は、それぞれ、挿入、更新、削除の各操作が実行される前に発生します。 | SqlDataSourceCommandEventArgs | SqlDataSourceCommandEventHandler |
Selected、Inserted、Updated、Deleted は、それぞれ、データの取得、挿入、更新、削除の各操作が完了した後で発生します。 | SqlDataSourceStatusEventArgs | SqlDataSourceStatusEventHandler |

次のコード例は、SqlDataSource コントロールをストアド プロシージャで使用した後、その戻り値と出力パラメータの値を SqlDataSourceStatusEventArgs クラスを使ってチェックし、GridView コントロールに値を挿入する方法を示しています。ストアド プロシージャでは、GridView に表示するデータを選択しているほか、その他の情報 (整数の出力パラメータや戻り値など) を呼び出し元に返しています。SqlDataSource がストアド プロシージャで使用するパラメータは、Web フォームからの情報をストアド プロシージャに渡すためのパラメータと、フォームに情報を返すためのパラメータとで構成され、SelectParameters コレクションに格納されます。これらのパラメータの Direction プロパティは、Output および ReturnValue に設定されます。
<%@Page Language="VB" %> <%@Import Namespace="System.Data" %> <%@Import Namespace="System.Data.Common" %> <%@Import Namespace="System.Data.SqlClient" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat="server"> ' Clicking the Submit button explicitly refreshes the data ' by calling the Select() method. Private Sub Submit(source As Object, e As EventArgs) SqlDataSource1.Select(DataSourceSelectArguments.Empty) End Sub ' Submit ' This event handler is called after the Select() method is executed. Private Sub OnSelectedHandler(source As Object, e As SqlDataSourceStatusEventArgs) Dim cmd As IDbCommand cmd = e.Command Dim param As SqlParameter Label1.Text = "Parameter return values: " For Each param In cmd.Parameters ' Extract the name and value of the parameter. Label1.Text = Label1.Text & param.ParameterName & " - " & _ param.Value.ToString() Next End Sub ' OnSelectedHandler </SCRIPT> <html> <body> <form runat="server"> <asp:sqldatasource id="SqlDataSource1" runat="server" datasourcemode="DataSet" connectionstring="<%$ ConnectionStrings:MyNorthwind%>" selectcommand="getordertotal" onselected="OnSelectedHandler"> <selectparameters> <asp:querystringparameter name="empId" querystringfield="empId" /> <asp:parameter name="total" type="Int32" direction="Output" defaultvalue="0" /> <asp:parameter name="_ret" type="Int32" direction="ReturnValue" defaultvalue="0" /> </selectparameters> </asp:sqldatasource> <!-- CREATE PROCEDURE dbo.getordertotal @empId int, @total int OUTPUT as set nocount on select @total = count(1) from orders where employeeid=@empid; select * from orders where employeeID = @empId ; return (-1000); GO --> <asp:gridview id="GridView1" runat="server" allowpaging="True" pagesize="5" datasourceid="SqlDataSource1" /> <asp:button id="Button1" runat="server" onclick="Submit" text="Refresh Data" /> <asp:label id="Label1" runat="server" /> </form> </body> </html>
<%@Page Language="C#" %> <%@Import Namespace="System.Data" %> <%@Import Namespace="System.Data.Common" %> <%@Import Namespace="System.Data.SqlClient" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat="server"> // Clicking the Submit button explicitly refreshes the data // by calling the Select() method. private void Submit(Object source, EventArgs e) { SqlDataSource1.Select(DataSourceSelectArguments.Empty); } // This event handler is called after the Select() method is executed. private void OnSelectedHandler(Object source, SqlDataSourceStatusEventArgs e) { IDbCommand cmd = e.Command; Label1.Text = "Parameter return values: "; foreach (SqlParameter param in cmd.Parameters) { // Extract the value of the parameter. Label1.Text += param.ParameterName + " - " + param.Value.ToString(); } } </SCRIPT> <html> <body> <form runat="server"> <asp:sqldatasource id="SqlDataSource1" runat="server" datasourcemode="DataSet" connectionstring="<%$ ConnectionStrings:MyNorthwind%>" selectcommand="getordertotal" onselected="OnSelectedHandler"> <selectparameters> <asp:querystringparameter name="empId" querystringfield="empId" /> <asp:parameter name="total" type="Int32" direction="Output" defaultvalue="0" /> <asp:parameter name="_ret" type="Int32" direction="ReturnValue" defaultvalue="0" /> </selectparameters> </asp:sqldatasource> <!-- CREATE PROCEDURE dbo.getordertotal @empId int, @total int OUTPUT as set nocount on select @total = count(1) from orders where employeeid=@empid; select * from orders where employeeID = @empId ; return (-1000); GO --> <asp:gridview id="GridView1" runat="server" allowpaging="True" pagesize="5" datasourceid="SqlDataSource1" /> <asp:button id="Button1" runat="server" onclick="Submit" text="Refresh Data" /> <asp:label id="Label1" runat="server" /> </form> </body> </html>


System.EventArgs
System.Web.UI.WebControls.SqlDataSourceStatusEventArgs


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SqlDataSourceStatusEventArgs コンストラクタ
アセンブリ: System.Web (system.web.dll 内)

Dim command As DbCommand Dim affectedRows As Integer Dim exception As Exception Dim instance As New SqlDataSourceStatusEventArgs(command, affectedRows, exception)
public function SqlDataSourceStatusEventArgs ( command : DbCommand, affectedRows : int, exception : Exception )

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SqlDataSourceStatusEventArgs プロパティ

名前 | 説明 | |
---|---|---|
![]() | AffectedRows | データベース操作の影響を受けた行の数を取得します。 |
![]() | Command | データベースに送信されたデータベース コマンドを取得します。 |
![]() | Exception | データ操作中にデータベースによってスローされる例外のラッパーを取得します。 |
![]() | ExceptionHandled | データベースによりスローされた例外が処理されたかどうか示す値を取得または設定します。 |

SqlDataSourceStatusEventArgs メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

SqlDataSourceStatusEventArgs メンバ
データ操作の完了時に、SqlDataSource コントロールによって生成されたイベントのデータを提供します。
SqlDataSourceStatusEventArgs データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | SqlDataSourceStatusEventArgs | 指定された出力パラメータ、戻り値、および、データベース操作によって影響を受ける行数を使用して、SqlDataSourceStatusEventArgs クラスの新しいインスタンスを初期化します。 |

名前 | 説明 | |
---|---|---|
![]() | AffectedRows | データベース操作の影響を受けた行の数を取得します。 |
![]() | Command | データベースに送信されたデータベース コマンドを取得します。 |
![]() | Exception | データ操作中にデータベースによってスローされる例外のラッパーを取得します。 |
![]() | ExceptionHandled | データベースによりスローされた例外が処理されたかどうか示す値を取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からSqlDataSourceStatusEventArgsを検索する場合は、下記のリンクをクリックしてください。

- SqlDataSourceStatusEventArgsのページへのリンク