OdbcParameterCollection Class
Represents a collection of parameters relevant to an OdbcCommand as well as their respective mappings to columns in a DataSet. This class cannot be inherited.
For a list of all members of this type, see OdbcParameterCollection Members.
System.Object
System.MarshalByRefObject
System.Data.Odbc.OdbcParameterCollection
[Visual Basic] NotInheritable Public Class OdbcParameterCollection Inherits MarshalByRefObject Implements IDataParameterCollection, IList, ICollection, _ IEnumerable [C#] public sealed class OdbcParameterCollection : MarshalByRefObject, IDataParameterCollection, IList, ICollection, IEnumerable [C++] public __gc __sealed class OdbcParameterCollection : public MarshalByRefObject, IDataParameterCollection, IList, ICollection, IEnumerable [JScript] public class OdbcParameterCollection extends MarshalByRefObject implements IDataParameterCollection, IList, ICollection, IEnumerable
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
The number of parameters in the collection must be equal to the number of parameter placeholders within the command text, or the .NET Framework Data Provider for ODBC raises an error.
Example
[Visual Basic, C#, C++] The following example assumes that the data source has a table name MyTable and a stored procedure named MyProc, that is defined as:
create table MyTable (col1 int, col2 smallmoney, col3 decimal) create proc MyProc (@p1 int, @p2 smallmoney, @p3 decimal) as insert into MyTable values (@p1, @p2, @p3)
[Visual Basic, C#, C++] The example creates parameters and calls the MyProc stored procedure.
[Visual Basic] Public Sub CreateMyProc(myConnection As OdbcConnection) Dim myCommand As OdbcCommand = myConnection.CreateCommand() myCommand.CommandText = { call MyProc(?,?,?) } myCommand.Parameters.Add("", OdbcType.Int).Value = 1 myCommand.Parameters.Add("", OdbcType.Decimal).Value = 2 myCommand.Parameters.Add("", OdbcType.Decimal).Value = 3 End Sub ' CreateMyProc [C#] public void CreateMyProc(OdbcConnection myConnection) { OdbcCommand myCommand = myConnection.CreateCommand(); myCommand.CommandText = "{ call MyProc(?,?,?) }"; myCommand.Parameters.Add("", OdbcType.Int).Value = 1; myCommand.Parameters.Add("", OdbcType.Decimal).Value = 2; myCommand.Parameters.Add("", OdbcType.Decimal).Value = 3; } [C++] public: void CreateMyProc(OdbcConnection* myConnection) { OdbcCommand* myCommand = myConnection->CreateCommand(); myCommand->CommandText = S"{ call MyProc(?,?,?) }"; myCommand->Parameters->Add(S"", OdbcType::Int)->Value = __box(1); myCommand->Parameters->Add(S"", OdbcType::Decimal)->Value = __box(2); myCommand->Parameters->Add(S"", OdbcType::Decimal)->Value = __box(3); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Data.Odbc
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Data (in System.Data.dll)
See Also
OdbcParameterCollection Members | System.Data.Odbc Namespace