DB2Parameter.ParameterName Property
Gets or sets the name of the DB2Parameter.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Property ParameterName As String Implements _
IDataParameter.ParameterName
[C#]
public string ParameterName {get; set;}
[C++]
public: __property String* get_ParameterName();
public: __property void set_ParameterName(String*);
[JScript]
public function get ParameterName() : String;
public function set ParameterName(String);
- Implements:
- IDataParameter.ParameterName
Property value
The name of the DB2Parameter . The default is an empty string ("").
Remarks
When using named parameters (prefixed with @) or host variables (prefixed with :) in a DB2ParameterCollection, you must set ParameterName before executing a DB2Command that relies on parameters. If positioned parameters are used, any parameter names will be ignored during parameter object binding.
Parameter marker names are
case-insensitive, must be prefixed by the symbol '@'or by a colon ':', and can be made up of any
symbol that can be used as part of an SQL identifier. For details regarding SQL identifiers, see the
topic: Identifiers
in the Db2® data server
documentation. Using more than one type of parameter marker within the same statement is not
supported. This means that a statement using positioned parameters cannot contain named parameters
or host variables. Likewise, a statement using named parameters cannot contain host variables or
positioned parameters
Support for host variables, prefixed by a colon ':', is disabled by
default. To enable host variable support the HostVarParameters property must be
set to TRUE
in the connection string.
Example
[Visual Basic, C#] The following example assumes that the database has a table name MyTable and a stored procedure named MyProc, that is defined as:
create table MyTable (col1 int, col2 double, col3 decimal)
create proc MyProc (p1 int, p2 double, p3 decimal) language sql LABEL1:
begin insert into MyTable values (p1, p2, p3); end
[Visual Basic, C#] The example creates parameters and calls the MyProc stored procedure.
[Visual Basic]
Public Sub CallMyProc()
' Create and open DB2Connection myConnection.
Dim myCommand As DB2Command = myConnection.CreateCommand()
myCommand.CommandText = "call MyProc(@param1,@param2,@param3)"
Dim p1 As New DB2Parameter()
p1.ParameterName = "@param1"
p1.DB2Type = DB2Type.Integer
p1.Value = 1
Dim p2 As New DB2Parameter()
p2.ParameterName = "@param2"
p2.DB2Type = DB2Type.Double
p2.Value = 2
Dim p3 = new DB2Parameter()
p3.ParameterName = "@param3"
p3.DB2Type = DB2Type.Decimal
p3.Value = 3
// Add parameters to the myCommand.Parameters collection
// and then execute the command.
End Sub ' CallMyProc
[C#]
public void CallMyProc()
{
// Create and open DB2Connection myConnection.
DB2Command myCommand = myConnection.CreateCommand();
myCommand.CommandText = "call MyProc(@param1,@param2,@param3)";
Dim p1 As New DB2Parameter();
p1.ParameterName = "@param1";
p1.DB2Type = DB2Type.Integer;
p1.Value = 1;
Dim p2 As New DB2Parameter();
p2.ParameterName = "@param2";
p2.DB2Type = DB2Type.Double;
p2.Value = 2;
Dim p3 = new DB2Parameter();
p3.ParameterName = "@param3";
p3.DB2Type = DB2Type.Decimal;
p3.Value = 3;
// Add parameters to the myCommand.Parameters collection
// and then execute the command.
}