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 プロパティ



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

辞書ショートカット

すべての辞書の索引

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

   

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



SqlDataSourceView.UpdateParameters プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS