Upraviť

Zdieľať cez


OdbcParameter.ParameterName Property

Definition

Gets or sets the name of the OdbcParameter.

public:
 virtual property System::String ^ ParameterName { System::String ^ get(); void set(System::String ^ value); };
public:
 property System::String ^ ParameterName { System::String ^ get(); void set(System::String ^ value); };
public override string ParameterName { get; set; }
public string ParameterName { get; set; }
member this.ParameterName : string with get, set
Public Overrides Property ParameterName As String
Public Property ParameterName As String

Property Value

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

Implements

Examples

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)  

The following example creates parameters and calls the MyProc stored procedure:

Public Sub CreateMyProc(connection As OdbcConnection)  

   Dim command As OdbcCommand = connection.CreateCommand()  

   command.CommandText = "{ call MyProc(?,?,?) }"  
   command.Parameters.Add("", OdbcType.Int).Value = 1  
   command.Parameters.Add("", OdbcType.Decimal).Value = 2  
   command.Parameters.Add("", OdbcType.Decimal).Value = 3  

End Sub  
public void CreateMyProc(OdbcConnection connection)   
{  
   OdbcCommand command = myConnection.CreateCommand();  

   command.CommandText = "{ call MyProc(?,?,?) }";  
   command.Parameters.Add("", OdbcType.Int).Value = 1;  
   command.Parameters.Add("", OdbcType.Decimal).Value = 2;  
   command.Parameters.Add("", OdbcType.Decimal).Value = 3;  
}  

Remarks

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 instead of by parameter name. Parameter names can be supplied, but will be ignored during parameter object binding.

Applies to

See also