次の方法で共有


OdbcParameterCollection.Add メソッド (String, OdbcType)

メモ : この名前空間、クラス、およびメンバは、.NET Framework Version 1.1 だけでサポートされています。

パラメータの名前とデータ型を指定して、 OdbcParameterOdbcParameterCollection に追加します。

Overloads Public Function Add( _
   ByVal parameterName As String, _   ByVal odbcType As OdbcType _) As OdbcParameter
[C#]
public OdbcParameter Add(stringparameterName,OdbcTypeodbcType);
[C++]
public: OdbcParameter* Add(String* parameterName,OdbcTypeodbcType);
[JScript]
public function Add(
   parameterName : String,odbcType : OdbcType) : OdbcParameter;

パラメータ

  • parameterName
    パラメータの名前。
  • odbcType
    OdbcType 値の 1 つ。

戻り値

新しい OdbcParameter オブジェクトのインデックス。

使用例

[Visual Basic, C#, C++] OdbcParameterCollection を作成し、 OdbcParameter をコレクションに追加する方法を次の例に示します。

 
Public Sub CreateOdbcParamColl(myConn As OdbcConnection)
  Dim myCommand As OdbcCommand = New OdbcCommand("SELECT * FROM Customers WHERE CustomerID = ?", myConn)
  Dim myParamCollection As OdbcParameterCollection = myCommand.Parameters
  Dim myParm As Object = New OdbcParameter("CustomerID", OdbcType.VarChar)
  Dim pIndex As Integer = myParamCollection.Add(myParm)
End Sub 'CreateOdbcParamColl

[C#] 
public void CreateOdbcParamColl() {
    OdbcCommand myCommand = new OdbcCommand("SELECT * FROM Customers WHERE CustomerID = ?", myConn);
    OdbcParameterCollection myParamCollection = myCommand.Parameters;
    object myParm = new OdbcParameter("CustomerID", OdbcType.VarChar);
    int pIndex = myParamCollection.Add(myParm);
 }

[C++] 
public:
void CreateOdbcParamColl() {
    OdbcCommand* myCommand = new OdbcCommand(S"SELECT * FROM Customers WHERE CustomerID = ?", myConn);
    OdbcParameterCollection* myParamCollection = myCommand->Parameters;
    Object* myParm = new OdbcParameter(S"CustomerID", OdbcType::VarChar);
    int pIndex = myParamCollection->Add(myParm);
 }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

OdbcParameterCollection クラス | OdbcParameterCollection メンバ | System.Data.Odbc 名前空間 | OdbcParameterCollection.Add オーバーロードの一覧