指定したインデックス位置にある SqlParameter を取得します。
[C#] C# では、このプロパティは SqlParameterCollection クラスのインデクサになります。
Overloads Public Default Property Item( _
ByVal index As Integer _) As SqlParameter
[C#]
public SqlParameter this[intindex] {get; set;}
[C++]
public: __property SqlParameter* get_Item(intindex);public: __property void set_Item(intindex, SqlParameter*);
[JScript]
returnValue = SqlParameterCollectionObject.Item(index);SqlParameterCollectionObject.Item(index) = returnValue;またはreturnValue = SqlParameterCollectionObject(index);SqlParameterCollectionObject(index) = returnValue;
[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。
引数 [JScript]
- index
取得するパラメータの、0 から始まるインデックス番号。
パラメータ [Visual Basic, C#, C++]
- index
取得するパラメータの、0 から始まるインデックス番号。
プロパティ値
指定したインデックス位置にある SqlParameter 。
例外
例外の種類 | 条件 |
---|---|
IndexOutOfRangeException | 指定したインデックスが存在しません。 |
使用例
[C#, C++] コレクションの親、およびコレクション内のすべての SqlParameter オブジェクトを表示する例を次に示します。この例では、 SqlParameterCollection が SqlCommand によって既に作成されていることを前提にしています。
using System;
using System.Xml;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Windows.Forms;
public class Form1: Form
{
protected DataSet DataSet1;
protected DataGrid dataGrid1;
protected SqlCommand myCmd;
public void ShowSqlParams() {
myCmd = new SqlCommand();
string myParamList = "";
for(int i=0; i < myCmd.Parameters.Count; i++) {
myParamList += myParamList + " " + myCmd.Parameters[i].ToString() + "\n";
}
MessageBox.Show("myChildren:\n" + myParamList);
}
}
[C++]
#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Data.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Xml;
using namespace System::Data;
using namespace System::Data::SqlClient;
using namespace System::Data::Common;
using namespace System::Windows::Forms;
public __gc class Form1: public Form
{
protected:
DataSet* DataSet1;
protected:
DataGrid* dataGrid1;
protected:
SqlCommand* myCmd;
public:
void ShowSqlParams() {
myCmd = new SqlCommand();
String* myParamList = S"";
for(int i=0; i < myCmd->Parameters->Count; i++) {
myParamList = String::Concat( myParamList, myParamList, S" ", myCmd->Parameters->Item[i], S"\n" );
}
MessageBox::Show(String::Format( S"myChildren:\n{0}", myParamList ));
}
};
[Visual Basic, JScript] Visual Basic および JScript のサンプルはありません。C# および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
SqlParameterCollection クラス | SqlParameterCollection メンバ | System.Data.SqlClient 名前空間 | SqlParameterCollection.Item オーバーロードの一覧