Parameter コンストラクター

定義

Parameter クラスの新しいインスタンスを初期化します。

オーバーロード

Parameter()

Parameter クラスの新しい既定のインスタンスを初期化します。

Parameter(String)

名前を指定して、Parameter クラスの新しいインスタンスを初期化します。

Parameter(Parameter)

指定した元のインスタンスの値を使用して、Parameter クラスの新しいインスタンスを初期化します。

Parameter(String, DbType)

指定した名前とデータベース型を使用して、Parameter クラスの新しいインスタンスを初期化します。

Parameter(String, TypeCode)

名前と型を指定して、Parameter クラスの新しいインスタンスを初期化します。

Parameter(String, DbType, String)

指定した名前、指定したデータベース型、およびその Parameter プロパティに指定した値を使用して、DefaultValue クラスの新しいインスタンスを初期化します。

Parameter(String, TypeCode, String)

Parameter プロパティに指定した名前、型、文字列を使用して、DefaultValue クラスの新しいインスタンスを初期化します。

Parameter()

Parameter クラスの新しい既定のインスタンスを初期化します。

public:
 Parameter();
public Parameter ();
Public Sub New ()

注釈

Parameterコンストラクターで作成されたParameter()オブジェクトは、そのすべてのプロパティの既定値で初期化されます。 プロパティは NameString.Empty初期化され、 Type プロパティは にTypeCode.Object初期化されDefaultValueDirection プロパティは にInputnull初期化されます。

適用対象

Parameter(String)

名前を指定して、Parameter クラスの新しいインスタンスを初期化します。

public:
 Parameter(System::String ^ name);
public Parameter (string name);
new System.Web.UI.WebControls.Parameter : string -> System.Web.UI.WebControls.Parameter
Public Sub New (name As String)

パラメーター

name
String

パラメーターの名前。

次のコード例では、 クラスを拡張Parameterして インスタンスの Parameter(String) プロパティを初期化するクラスからコンストラクターをName呼び出す方法を示します。 このコード例は、クラスの概要に関して提供されるより大きな例の Parameter 一部です。

// The StaticParameter(string, object) constructor
// initializes the DataValue property and calls the
// Parameter(string) constructor to initialize the Name property.
public StaticParameter(string name, object value) : base(name) {
  DataValue = value;
}
' The StaticParameter(string, object) constructor
' initializes the DataValue property and calls the
' Parameter(string) constructor to initialize the Name property.
 Public Sub New(name As String, value As Object)
    MyBase.New(name)
    DataValue = value
 End Sub

注釈

Parameterコンストラクターを使用して作成されたParameter(String)オブジェクトは、その他のプロパティの指定されたname既定値と既定値で初期化されます。 プロパティは TypeTypeCode.Object初期化され、 Direction プロパティは に Input初期化され、 DefaultValue プロパティは に null初期化されます。

こちらもご覧ください

適用対象

Parameter(Parameter)

指定した元のインスタンスの値を使用して、Parameter クラスの新しいインスタンスを初期化します。

protected:
 Parameter(System::Web::UI::WebControls::Parameter ^ original);
protected Parameter (System.Web.UI.WebControls.Parameter original);
new System.Web.UI.WebControls.Parameter : System.Web.UI.WebControls.Parameter -> System.Web.UI.WebControls.Parameter
Protected Sub New (original As Parameter)

パラメーター

original
Parameter

現在のインスタンスの初期化の基になる Parameter インスタンス。

次のコード例では、 クラスを拡張するクラスからコンストラクターを Parameter(Parameter) 呼び出して、 クラスの Parameter 正しいオブジェクト複製動作を実装する方法を示します。 このコード例は、クラスの概要に関して提供されるより大きな例の Parameter 一部です。

// The StaticParameter copy constructor is provided to ensure that
// the state contained in the DataValue property is copied to new
// instances of the class.
protected StaticParameter(StaticParameter original) : base(original) {
  DataValue = original.DataValue;
}

// The Clone method is overridden to call the
// StaticParameter copy constructor, so that the data in
// the DataValue property is correctly transferred to the
// new instance of the StaticParameter.
protected override Parameter Clone() {
  return new StaticParameter(this);
}
' The StaticParameter copy constructor is provided to ensure that
' the state contained in the DataValue property is copied to new
' instances of the class.
Protected Sub New(original As StaticParameter)
   MyBase.New(original)
   DataValue = original.DataValue
End Sub

' The Clone method is overridden to call the
' StaticParameter copy constructor, so that the data in
' the DataValue property is correctly transferred to the
' new instance of the StaticParameter.
Protected Overrides Function Clone() As Parameter
   Return New StaticParameter(Me)
End Function

注釈

コンストラクターは Parameter(Parameter) 、インスタンスの protected 複製に使用されるコピー コンストラクターです Parameter 。 、DirectionTypeDefaultValue、および ConvertEmptyStringToNull の各プロパティのName値はすべて、新しいインスタンスに転送されます。

こちらもご覧ください

適用対象

Parameter(String, DbType)

指定した名前とデータベース型を使用して、Parameter クラスの新しいインスタンスを初期化します。

public:
 Parameter(System::String ^ name, System::Data::DbType dbType);
public Parameter (string name, System.Data.DbType dbType);
new System.Web.UI.WebControls.Parameter : string * System.Data.DbType -> System.Web.UI.WebControls.Parameter
Public Sub New (name As String, dbType As DbType)

パラメーター

name
String

パラメーターの名前。

dbType
DbType

パラメーターのデータベース型。

注釈

Parameterコンストラクターを使用してParameter(String, DbType)作成されたオブジェクトは、指定された name パラメーターと dbType パラメーター、および他のプロパティの既定値で初期化されます。 プロパティは DirectionInput初期化され、 DefaultValue プロパティは に null初期化されます。

適用対象

Parameter(String, TypeCode)

名前と型を指定して、Parameter クラスの新しいインスタンスを初期化します。

public:
 Parameter(System::String ^ name, TypeCode type);
public Parameter (string name, TypeCode type);
new System.Web.UI.WebControls.Parameter : string * TypeCode -> System.Web.UI.WebControls.Parameter
Public Sub New (name As String, type As TypeCode)

パラメーター

name
String

パラメーターの名前。

type
TypeCode

プロパティの型を表す TypeCode

次のコード例では、 クラスを拡張Parameterして インスタンスの Parameter(String, TypeCode) プロパティと Type プロパティを初期化Nameするクラスからコンストラクターを呼び出す方法を示します。 このコード例は、クラスの概要に関して提供されるより大きな例の Parameter 一部です。

// The StaticParameter(string, TypeCode, object) constructor
// initializes the DataValue property and calls the
// Parameter(string, TypeCode) constructor to initialize the Name and
// Type properties.
public StaticParameter(string name, TypeCode type, object value) : base(name, type) {
  DataValue = value;
}
' The StaticParameter(string, TypeCode, object) constructor
' initializes the DataValue property and calls the
' Parameter(string, TypeCode) constructor to initialize the Name and
' Type properties.
Public Sub New(name As String, type As TypeCode, value As Object)
   MyBase.New(name, type)
   DataValue = value
End Sub

注釈

Parameterコンストラクターを使用してParameter(String, TypeCode)作成されたオブジェクトは、指定された name パラメーターと type パラメーター、およびその他のプロパティの既定値を使用して初期化されます。 プロパティは DirectionInput初期化され、 DefaultValue プロパティは に null初期化されます。

こちらもご覧ください

適用対象

Parameter(String, DbType, String)

指定した名前、指定したデータベース型、およびその Parameter プロパティに指定した値を使用して、DefaultValue クラスの新しいインスタンスを初期化します。

public:
 Parameter(System::String ^ name, System::Data::DbType dbType, System::String ^ defaultValue);
public Parameter (string name, System.Data.DbType dbType, string defaultValue);
new System.Web.UI.WebControls.Parameter : string * System.Data.DbType * string -> System.Web.UI.WebControls.Parameter
Public Sub New (name As String, dbType As DbType, defaultValue As String)

パラメーター

name
String

Parameter インスタンスの名前。

dbType
DbType

Parameter インスタンスのデータベース型。

defaultValue
String

Parameter の呼び出し時に、Parameter がまだ初期化されていない値にバインドされている場合は、Evaluate(HttpContext, Control) インスタンスの既定値。

注釈

インスタンスの Parameter プロパティは DirectionInput初期化されます。

適用対象

Parameter(String, TypeCode, String)

Parameter プロパティに指定した名前、型、文字列を使用して、DefaultValue クラスの新しいインスタンスを初期化します。

public:
 Parameter(System::String ^ name, TypeCode type, System::String ^ defaultValue);
public Parameter (string name, TypeCode type, string defaultValue);
new System.Web.UI.WebControls.Parameter : string * TypeCode * string -> System.Web.UI.WebControls.Parameter
Public Sub New (name As String, type As TypeCode, defaultValue As String)

パラメーター

name
String

パラメーターの名前。

type
TypeCode

プロパティの型を表す TypeCode

defaultValue
String

Parameter の呼び出し時に、Evaluate(HttpContext, Control) がまだ初期化されていない値にバインドされている場合に、パラメーターの既定値として使用する文字列。

次のコード例では、 コンストラクターを使用して、 メソッドを Parameter(String, TypeCode, String) 呼び出す前にコントロールのコレクションに UpdateParameters update パラメーター オブジェクトを追加する AccessDataSource 方法を Update 示します。

<script runat="server">
private void UpdateRecords(Object source, EventArgs e)
{
  // This method is an example of batch updating using a
  // data source control. The method iterates through the rows
  // of the GridView, extracts each CheckBox from the row and, if
  // the CheckBox is checked, updates data by calling the Update
  // method of the data source control, adding required parameters
  // to the UpdateParameters collection.
  CheckBox cb;
  foreach(GridViewRow row in this.GridView1.Rows) {
    cb = (CheckBox) row.Cells[0].Controls[1];
    if(cb.Checked) {
      string oid = (string) row.Cells[1].Text;
      MyAccessDataSource.UpdateParameters.Add(new Parameter("date",TypeCode.DateTime,DateTime.Now.ToString()));
      MyAccessDataSource.UpdateParameters.Add(new Parameter("orderid",TypeCode.String,oid));
      MyAccessDataSource.Update();
      MyAccessDataSource.UpdateParameters.Clear();
    }
  }
}
</script>
<script runat="server">
Private Sub UpdateRecords(source As Object, e As EventArgs)

  ' This method is an example of batch updating using a
  ' data source control. The method iterates through the rows
  ' of the GridView, extracts each CheckBox from the row and, if
  ' the CheckBox is checked, updates data by calling the Update
  ' method of the data source control, adding required parameters
  ' to the UpdateParameters collection.

  Dim cb As CheckBox
  Dim row As GridViewRow

  For Each row In GridView1.Rows

    cb = CType(row.Cells(0).Controls(1), CheckBox)
    If cb.Checked Then

      Dim oid As String
      oid = CType(row.Cells(1).Text, String)

      Dim param1 As New Parameter("date", TypeCode.DateTime, DateTime.Now.ToString())
      MyAccessDataSource.UpdateParameters.Add(param1)

      Dim param2 As New Parameter("orderid", TypeCode.String, oid)
      MyAccessDataSource.UpdateParameters.Add(param2)

      MyAccessDataSource.Update()
      MyAccessDataSource.UpdateParameters.Clear()
    End If
  Next
End Sub ' UpdateRecords
</script>

注釈

Parameterコンストラクターで作成されたParameter(String, TypeCode, String)オブジェクトは、指定されたnameパラメーターとtypeパラメーターを使用して初期化され、プロパティ値がDefaultValue割り当てられます。 Direction プロパティは Input に初期化されます。

こちらもご覧ください

適用対象