SqlDataSourceView.UpdateParameters プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SqlDataSourceView.UpdateParameters プロパティの意味・解説 

SqlDataSourceView.UpdateParameters プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

UpdateCommand プロパティによって使用されるパラメータを格納するパラメータ コレクションを取得します。

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

Public ReadOnly Property
 UpdateParameters As ParameterCollection
Dim instance As SqlDataSourceView
Dim value As ParameterCollection

value = instance.UpdateParameters
public ParameterCollection UpdateParameters { get;
 }
public:
property ParameterCollection^ UpdateParameters {
    ParameterCollection^ get ();
}
/** @property */
public ParameterCollection get_UpdateParameters ()
public function get UpdateParameters
 () : ParameterCollection

プロパティ値
UpdateCommand プロパティによって使用されるパラメータを格納している ParameterCollection。

解説解説

UpdateCommand プロパティにパラメータ化された SQL クエリが含まれている場合、UpdateParameters コレクションには、SQL 文字列内のパラメータ プレースホルダに対応する Parameter オブジェクトが含まれます。

パラメータ名は、OldValuesParameterFormatString プロパティの影響を受けることがあります。特に、パラメータ名が DataKeyNames プロパティを使用して指定したキーなどの主キーを識別している場合、または ConflictDetection プロパティが CompareAllValues 値に設定され、oldValues のセットが対応するデータ メソッドに渡される削除と更新の場合がこれに該当します。この場合、書式指定文字列が oldValues コレクションの各パラメータ名に割り当てられます。

ADO.NET プロバイダによっては、UpdateParameters コレクションのパラメータの順序が重要になる場合があります。System.Data.OleDb プロバイダおよび System.Data.Odbc プロバイダは、コレクション内のパラメータを、パラメータ化された SQL クエリでの指定順序に従って関連付けます。SqlDataSource コントロールの既定の ADO.NET プロバイダである System.Data.SqlClient プロバイダは、パラメータ名と、SQL クエリ内のプレースホルダ エイリアスとを照らし合わせることにより、コレクション内のパラメータを関連付けます。パラメータ化された SQL クエリとコマンドの詳細については、「SqlDataSource コントロールにおけるパラメータの使用」を参照してください。

使用例使用例

SqlDataSource コントロールを使用してデータを DropDownList コントロールに表示し、[Submit] ボタンをクリックするとデータが更新される方法を次のコード例に示します。UpdateCommand プロパティは、パラメータ化された SQL ステートメントで設定され、2 つの ControlParameter パラメータが UpdateParameters コレクションに追加されています。[Submit] ボタンがクリックされると、OnClick イベントが処理され、Update メソッドが明示的に呼び出されます。

<%@Page  Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">

 Sub On_Click(ByVal source As
 Object, ByVal e As EventArgs)
    Try
        SqlDataSource1.Update()
    Catch except As Exception
        ' Handle the Exception.
    End Try

    Label2.Text="The record was updated successfully!"

 End Sub 'On_Click
</SCRIPT>

<HTML>
  <BODY>
    <FORM runat="server">
      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
          SelectCommand="SELECT EmployeeID, LastName, Address
 FROM Employees"
          UpdateCommand="UPDATE Employees SET Address=@Address
 WHERE EmployeeID=@EmployeeID">
          <UpdateParameters>
              <asp:ControlParameter Name="Address"
 ControlId="TextBox1" PropertyName="Text"/>
              <asp:ControlParameter Name="EmployeeID"
 ControlId="DropDownList1" PropertyName="SelectedValue"/>
          </UpdateParameters>
      </asp:SqlDataSource>

      <asp:DropDownList
          id="DropDownList1"
          runat="server"
          DataTextField="LastName"
          DataValueField="EmployeeID"
          DataSourceID="SqlDataSource1">
      </asp:DropDownList>

      <P>
      <asp:Label id="Label1" runat="server"
 Text="Enter a new address for the selected user."
 />
      <asp:TextBox id="TextBox1" runat="server"
 />
      <asp:Button id="Submit" runat="server"
 Text="Submit" OnClick="On_Click"
 />

      <P><asp:Label id="Label2" runat="server"
 Text="" />
    </FORM>
  </BODY>
</HTML>
<%@Page  Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
 private void On_Click(Object source, EventArgs
 e) {
    try {
        SqlDataSource1.Update();
    }
    catch (Exception except) {
        // Handle the Exception.
    }

    Label2.Text="The record was updated successfully!";
 }
</SCRIPT>

<HTML>
  <BODY>
    <FORM runat="server">
      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
          SelectCommand="SELECT EmployeeID, LastName, Address FROM Employees"
          UpdateCommand="UPDATE Employees SET Address=@Address WHERE EmployeeID=@EmployeeID">
          <UpdateParameters>
              <asp:ControlParameter Name="Address" ControlId="TextBox1"
 PropertyName="Text"/>
              <asp:ControlParameter Name="EmployeeID" ControlId="DropDownList1"
 PropertyName="SelectedValue"/>
          </UpdateParameters>
      </asp:SqlDataSource>

      <asp:DropDownList
          id="DropDownList1"
          runat="server"
          DataTextField="LastName"
          DataValueField="EmployeeID"
          DataSourceID="SqlDataSource1">
      </asp:DropDownList>

      <P>
      <asp:Label id="Label1" runat="server" Text="Enter
 a new address for the selected user."
 />
      <asp:TextBox id="TextBox1" runat="server" />
      <asp:Button id="Submit" runat="server" Text="Submit"
 OnClick="On_Click" />

      <P><asp:Label id="Label2" runat="server" Text=""
 />

    </FORM>
  </BODY>
</HTML>
<%@Page  Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
 private void On_Click(Object source, System.EventArgs
 e)
 {
    try {
       SqlDataSource1.Update();
    }
    catch (Exception except) {
        // Handle the Exception.
    }
    Label2.set_Text("The record was updated successfully!");
 } //On_Click
</SCRIPT>

<HTML>
  <BODY>
    <FORM runat="server">
      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial
 Catalog=Northwind;"
          SelectCommand="SELECT EmployeeID, LastName, Address FROM Employees"
          UpdateCommand="UPDATE Employees SET Address=@Address WHERE EmployeeID=@EmployeeID">
          <UpdateParameters>
              <asp:ControlParameter Name="Address" ControlId="TextBox1"
 PropertyName="Text"/>
              <asp:ControlParameter Name="EmployeeID" ControlId="DropDownList1"
 PropertyName="SelectedValue"/>
          </UpdateParameters>
      </asp:SqlDataSource>

      <asp:DropDownList
          id="DropDownList1"
          runat="server"
          DataTextField="LastName"
          DataValueField="EmployeeID"
          DataSourceID="SqlDataSource1">
      </asp:DropDownList>

      <P>
      <asp:Label id="Label1" runat="server" Text="Enter
 a new address for the selected user."
 />
      <asp:TextBox id="TextBox1" runat="server" />
      <asp:Button id="Submit" runat="server" Text="Submit"
 OnClick="On_Click" />

      <P><asp:Label id="Label2" runat="server" Text=""
 />

    </FORM>
  </BODY>
</HTML>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlDataSourceView クラス
SqlDataSourceView メンバ
System.Web.UI.WebControls 名前空間
ExecuteUpdate
Update
SqlDataSourceView.UpdateCommand プロパティ



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

SqlDataSourceView.UpdateParameters プロパティのお隣キーワード
検索ランキング

   

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



SqlDataSourceView.UpdateParameters プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS