-
Calling Stored Procedure Does Not Return Results C#
I hope someone can help.
I am trying to call a DB2 stored procedure in C# to return a number. In the stored procedure the number increments but does not return the value so I know that the procedure gets executed.
This is code that is being executed:
// create the connection to the db
string strConnection = "Database=database;User ID=userid;Password=password;Server=server.name.us;Persist Security Info=True";
DB2Connection connection = new DB2Connection(strConnection);
connection.Open();
// Call stored procedure to get p_id_ncl value
DB2Transaction trans = connection.BeginTransaction();
DB2Command spCommand = new DB2Command("DHECPROC.SIPSEEDS", connection);
spCommand.CommandType = CommandType.StoredProcedure;
spCommand.Transaction = trans;
DB2Parameter inParmSchema = new DB2Parameter("@pschema", DB2Type.Char);
inParmSchema.Direction = ParameterDirection.Input;
inParmSchema.Value = "DHECCL";
DB2Parameter inParmTable = new DB2Parameter("@ptable", DB2Type.Char);
inParmTable.Direction = ParameterDirection.Input;
inParmTable.Value = "TNCLIENT";
DB2Parameter inParmColumn = new DB2Parameter("@p_id_ncl", DB2Type.Char);
inParmColumn.Direction = ParameterDirection.Input;
inParmColumn.Value = "P_ID_NCL";
DB2Parameter outParmNClient = new DB2Parameter("@thisid", DB2Type.Decimal);
outParmNClient.Direction = ParameterDirection.Output;
spCommand.Parameters.Add(inParmSchema);
spCommand.Parameters.Add(inParmTable);
spCommand.Parameters.Add(inParmColumn);
spCommand.Parameters.Add(outParmNClient);
spCommand.Transaction = trans;
spCommand.ExecuteReader();
nextId = (Decimal)spCommand.Parameters[3].Value;
I get a null value back from the database. Any clues to what I'm doing wrong?
Thanks in advance,
Greg