DB2®Parameter.SourceColumn Property
Gets or sets the name of the source column mapped to the DataSet and used for loading or returning the Value.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Property SourceColumn As String Implements _
IDataParameter.SourceColumn
[C#]
public string SourceColumn {get; set;}
[C++]
public: __property String* get_SourceColumn();
public: __property void set_SourceColumn(String*);
[JScript]
public function get SourceColumn() : String;
public function set SourceColumn(String);
- Implements:
- IDataParameter.SourceColumn
Property value
The name of the source column that will be used to set the value of this parameter. The default is an empty string ("").
Remarks
When SourceColumn is set to anything other than an empty string, the value of the parameter is retrieved from the column with the SourceColumn name. If Direction is set to Input, the value is taken from the DataSet. If Direction is set to Output, the value is taken from the database. A Direction of InputOutput is a combination of both.
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 timestamp)
create proc MyProc (p1 int, p2 double, p3 timestamp OUT) language sql LABEL1:
begin insert into MyTable (col1, col2) values (p1, p2); 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(?,?,?) }"
Dim p1 As New DB2Parameter("Name1", DB2Type.Integer)
p1.Value = 1
p1.Direction = ParameterDirection.Input
Dim p2 As New DB2Parameter("Name2", DB2Type.Double)
p2.Value = 2
p2.Direction = ParameterDirection.Input
Dim p3 As NewDB2Parameter("Name3", DB2Type.Decimal)
p3.SourceColumn = "col3"
p3.Direction = ParameterDirection.Output
// Add parameters to the myCommand.Parameters collection
// in the order in which they were created 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(?,?,?)";
DB2Parameter p1 = new DB2Parameter("Name1", DB2Type.Integer);
p1.Value = 1;
p1.Direction = ParameterDirection.Input;
DB2Parameter p2 = new DB2Parameter("Name2", DB2Type.Double);
p2.Value = 2;
p2.Direction = ParameterDirection.Input;
DB2Parameter p3 = new DB2Parameter("Name3", DB2Type.Decimal);
p3.SourceColumn = "col3";
p3.Direction = ParameterDirection.Output;
// Add parameters to the myCommand.Parameters collection
// in the order in which they were created, and then execute the command.
}