This documentation is archived and is not being maintained.

OdbcParameter.ParameterName Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Gets or sets the name of the OdbcParameter.

[Visual Basic]
Public Overridable Property ParameterName As String  Implements _
public virtual string ParameterName {get; set;}
public: __property virtual String* get_ParameterName();
public: __property virtual void set_ParameterName(String*);
public function get ParameterName() : String;
public function set ParameterName(String);

Property Value

The name of the OdbcParameter. The default is an empty string ("").




Instead of named parameters, the ODBC .NET Provider uses positional parameters that are marked with a question mark (?) in the syntax of the command text. Parameter objects in the OdbcParameterCollection and the actual parameters accepted by the stored procedure or parameterized SQL statement correspond to each other based on the order in which the OdbcParameter objects are inserted into the collection rather than by parameter name. Parameter names can be supplied, but will be ignored during parameter object binding.


[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

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;

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 Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

OdbcParameter Class | OdbcParameter Members | System.Data.Odbc Namespace