SqlDataSourceStatusEventArgsとは? わかりやすく解説

SqlDataSourceStatusEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

データ操作完了時に、SqlDataSource コントロールによって生成されイベントデータ提供します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Class SqlDataSourceStatusEventArgs
    Inherits EventArgs
Dim instance As SqlDataSourceStatusEventArgs
public class SqlDataSourceStatusEventArgs :
 EventArgs
public ref class SqlDataSourceStatusEventArgs
 : public EventArgs
public class SqlDataSourceStatusEventArgs extends
 EventArgs
public class SqlDataSourceStatusEventArgs extends
 EventArgs
解説解説

SqlDataSourceStatusEventArgs クラスは、データ ソース コントロールによって実行されデータベース操作完了後、SelectedUpdated、Inserted、Deleted の各イベントで、これらの操作に関する情報を渡すために使用されます。この情報には、操作によって影響受けた行数データ ソース操作実行するために使用した DbCommand オブジェクト発生した例外情報などが含まれます。SelectedUpdatedInsertedDeleted の各イベント処理するためのイベント ハンドラ デリゲート追加することで、このデータチェックして必要な追加ポスト プロセス実行できます

SqlDataSource コントロールは、データ操作過程で、基になるデータ オブジェクト操作する際に利用できる数多くイベント公開してます。次の表は、SqlDataSource コントロール使用したデータ操作一連の流れ対応するさまざまなイベントわかりやすく紹介するために、各種イベントと、個々イベント対応する EventArgs、およびイベント ハンドラ クラスをまとめたものです。

イベント

イベント引数

イベント ハンドラ

Selecting はデータ取得され前に発生します

SqlDataSourceSelectingEventArgs

SqlDataSourceSelectingEventHandler

Inserting、Updating、および、Deleting は、それぞれ挿入更新削除の各操作実行される前に発生します

SqlDataSourceCommandEventArgs

SqlDataSourceCommandEventHandler

SelectedInsertedUpdatedDeleted は、それぞれデータ取得挿入更新削除の各操作完了した後で発生します

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>
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.EventArgs
    System.Web.UI.WebControls.SqlDataSourceStatusEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlDataSourceStatusEventArgs メンバ
System.Web.UI.WebControls 名前空間
SqlDataSourceStatusEventHandler
SqlDataSource クラス
SqlDataSource.Selected イベント
SqlDataSource.Updated イベント
SqlDataSource.Inserted イベント
SqlDataSource.Deleted イベント

SqlDataSourceStatusEventArgs コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定され出力パラメータ戻り値、および、データベース操作によって影響を受ける行数使用して、SqlDataSourceStatusEventArgs クラス新しインスタンス初期化します。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    command As DbCommand, _
    affectedRows As Integer, _
    exception As Exception _
)
Dim command As DbCommand
Dim affectedRows As Integer
Dim exception As Exception

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

パラメータ

command

SqlDataSource コントロールによってデータベース送信されるデータベース クエリコマンド、またはストアド プロシージャを表す DbCommand。

affectedRows

該当する場合は、データベース操作影響受けた行数

exception

該当する場合は、データベース操作によってスローされた Exception

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlDataSourceStatusEventArgs クラス
SqlDataSourceStatusEventArgs メンバ
System.Web.UI.WebControls 名前空間
Command
AffectedRows

SqlDataSourceStatusEventArgs プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

SqlDataSourceStatusEventArgs クラス
System.Web.UI.WebControls 名前空間
SqlDataSourceStatusEventHandler
SqlDataSource クラス
SqlDataSource.Selected イベント
SqlDataSource.Updated イベント
SqlDataSource.Inserted イベント
SqlDataSource.Deleted イベント

SqlDataSourceStatusEventArgs メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

SqlDataSourceStatusEventArgs クラス
System.Web.UI.WebControls 名前空間
SqlDataSourceStatusEventHandler
SqlDataSource クラス
SqlDataSource.Selected イベント
SqlDataSource.Updated イベント
SqlDataSource.Inserted イベント
SqlDataSource.Deleted イベント

SqlDataSourceStatusEventArgs メンバ

データ操作完了時に、SqlDataSource コントロールによって生成されイベントデータ提供します

SqlDataSourceStatusEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド SqlDataSourceStatusEventArgs 指定され出力パラメータ戻り値、および、データベース操作によって影響を受ける行数使用して、SqlDataSourceStatusEventArgs クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

SqlDataSourceStatusEventArgs クラス
System.Web.UI.WebControls 名前空間
SqlDataSourceStatusEventHandler
SqlDataSource クラス
SqlDataSource.Selected イベント
SqlDataSource.Updated イベント
SqlDataSource.Inserted イベント
SqlDataSource.Deleted イベント



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SqlDataSourceStatusEventArgs」の関連用語

SqlDataSourceStatusEventArgsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SqlDataSourceStatusEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS