See section 4.5.5, "Calling stored procedures", of the IBM Redbook, "Integrating DB2 Universal Database for iSeries with Microsoft ADO.NET" ( SG24-6440) for a discussion and examples of calling a stored proc.

The cmd.Parameters.Add statements that you are using mix the definition of the parameter with the assignment of the value. Parm 2 of the Add method is used to set the characteristics of the parm, not its value.

Consider using the following:

cmd.CommandType = CommandType.Text;
cmd.Parameters["@SSN"].Value = timesheet.EmployeeUniqueKey.ToString("D10"));
// etc.

Craig Pelkie

----- Original Message ----- From: "Mike" <koldark@xxxxxxxxx>
To: ".net use with the System i" <systemidotnet@xxxxxxxxxxxx>
Sent: Tuesday, July 06, 2010 12:12 PM
Subject: [SystemiDotNet] Problems with Executing an External Stored Procedure

I am trying to call an external stored procedure (calls an RPG program). I
keep getting the following error:

"*Exception Details: *IBM.Data.DB2.iSeries.iDB2SQLErrorException: SQL0104
Token @SSN was not valid. Valid tokens: :."

Here is my code:

using (iDB2Connection conn = new iDB2Connection(_CONNSTRING))

string sqlStatement = "MPRLIB.SIGNTIMESHEET (@SSN,
//string sqlStatement = "MPRLIB.SIGNTIMESHEET (?, ?, ?, ?,

iDB2Command cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = sqlStatement;
GetJobHoursTotal(timesheet.Id).ToString("00000.000").Replace(".", ""));
cmd.Parameters.Add("@COMMENT", timesheet.EmployeeComments);


I can't seem to figure out what is happening or why I am getting the above
error. My connection string looks like:

private const string _CONNSTRING =

Could it be a library list issue? The program just references one file that
is in the library list. Any suggestions?

Mike Wills
P: (507) 933-0880 | Skype: koldark
This is the .net use with the System i (SystemiDotNet) mailing list
To post a message email: SystemiDotNet@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: SystemiDotNet-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].