SqlDataSourceView.InsertParameters プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As SqlDataSourceView Dim value As ParameterCollection value = instance.InsertParameters
InsertCommand プロパティによって使用されるパラメータを格納している ParameterCollection。

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

SqlDataSource コントロールと簡単な Web フォーム ページを使用してデータベースにデータを挿入する方法を次のコード例に示します。テーブル内の現在のデータが、DropDownList コントロールに表示されます。TextBox コントロールに値を入力し、[挿入] ボタンをクリックすることにより、新しいレコードを追加できます。[挿入] ボタンがクリックされると、指定された値がデータベースに挿入され、DropDownList が更新されます。
<%@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"> Private Sub InsertShipper (ByVal Source As Object, ByVal e As EventArgs) SqlDataSource1.Insert() End Sub ' InsertShipper </Script> <HTML> <BODY> <FORM runat="server"> <asp:dropdownlist id="DropDownList1" runat="server" datasourceid="SqlDataSource1" datatextfield="CompanyName" datavaluefield="ShipperID" /> <!-- Security Note: The SqlDataSource uses a FormParameter, Security Note: which does not perform validation of input from the client. Security Note: To validate the value of the FormParameter, handle the Inserting event. --> <asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:MyNorthwind %>" selectcommand="SELECT CompanyName,ShipperID FROM Shippers" insertcommand="INSERT INTO Shippers (CompanyName,Phone) VALUES (@CoName,@Phone)"> <insertparameters> <asp:formparameter name="CoName" formfield="CompanyNameBox" /> <asp:formparameter name="Phone" formfield="PhoneBox" /> </insertparameters> </asp:sqldatasource> <p><asp:textbox id="CompanyNameBox" runat="server" /> <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="CompanyNameBox" Display="Static" ErrorMessage="Please enter a company name." /> <p><asp:textbox id="PhoneBox" runat="server" /> <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="PhoneBox" Display="Static" ErrorMessage="Please enter a phone number." /> <p><asp:button id="Button1" runat="server" text="Insert New Shipper" onclick="InsertShipper" /> </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 InsertShipper (object source, EventArgs e) { SqlDataSource1.Insert(); } </Script> <HTML> <BODY> <FORM runat="server"> <asp:dropdownlist id="DropDownList1" runat="server" datasourceid="SqlDataSource1" datatextfield="CompanyName" datavaluefield="ShipperID" /> <!-- Security Note: The SqlDataSource uses a FormParameter, Security Note: which does not perform validation of input from the client. Security Note: To validate the value of the FormParameter, handle the Inserting event. --> <asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:MyNorthwind %>" selectcommand="SELECT CompanyName,ShipperID FROM Shippers" insertcommand="INSERT INTO Shippers (CompanyName,Phone) VALUES (@CoName ,@Phone)"> <insertparameters> <asp:formparameter name="CoName" formfield="CompanyNameBox" /> <asp:formparameter name="Phone" formfield="PhoneBox" /> </insertparameters> </asp:sqldatasource> <p><asp:textbox id="CompanyNameBox" runat="server" /> <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="CompanyNameBox" Display="Static" ErrorMessage="Please enter a company name." /> <p><asp:textbox id="PhoneBox" runat="server" /> <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="PhoneBox" Display="Static" ErrorMessage="Please enter a phone number." /> <p><asp:button id="Button1" runat="server" text="Insert New Shipper" onclick="InsertShipper" /> </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 InsertShipper(Object source, System.EventArgs e) { SqlDataSource1.Insert(); } //InsertShipper </Script> <HTML> <BODY> <FORM runat="server"> <asp:dropdownlist id="DropDownList1" runat="server" datasourceid="SqlDataSource1" datatextfield="CompanyName" datavaluefield="ShipperID" /> <asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;Connect Timeout=15" selectcommand="SELECT CompanyName,ShipperID FROM Shippers" insertcommand="INSERT INTO Shippers (CompanyName,Phone) VALUES (@CoName ,@Phone)"> <insertparameters> <asp:formparameter name="CoName" formfield="CompanyNameBox" /> <asp:formparameter name="Phone" formfield="PhoneBox" /> </insertparameters> </asp:sqldatasource> <p><asp:textbox id="CompanyNameBox" runat="server" /> <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="CompanyNameBox" Display="Static" ErrorMessage="Please enter a company name." /> <p><asp:textbox id="PhoneBox" runat="server" /> <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="PhoneBox" Display="Static" ErrorMessage="Please enter a phone number." /> <p><asp:button id="Button1" runat="server" text="Insert New Shipper" onclick="InsertShipper" /> </FORM> </BODY> </HTML>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からSqlDataSourceView.InsertParameters プロパティを検索する場合は、下記のリンクをクリックしてください。

- SqlDataSourceView.InsertParameters プロパティのページへのリンク