执行 DB2 外部存储过程时出现的问题
我正在尝试调用外部存储过程(调用 RPG 程序)。我不断收到以下错误:
“异常详细信息:IBM.Data.DB2.iSeries.iDB2SQLErrorException:SQL0104 令牌@SSN 无效。有效令牌::。”
这是我的代码:
using (iDB2Connection conn = new iDB2Connection(_CONNSTRING))
{
conn.Open();
string sqlStatement = "MPRLIB.SIGNTIMESHEET (@SSN, @SIGNATURE, @WORKSTATION, @TOTALHOURS, @COMMENT)";
//string sqlStatement = "MPRLIB.SIGNTIMESHEET (?, ?, ?, ?, ?)";
iDB2Command cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = sqlStatement;
cmd.Parameters.Add("@SSN", timesheet.EmployeeUniqueKey.ToString("0000000000"));
cmd.Parameters.Add("@SIGNATURE", timesheet.EmployeeTypedName);
cmd.Parameters.Add("@WORKSTATION", timesheet.EmployeeSignedComputer);
cmd.Parameters.Add("@TOTALHOURS", GetJobHoursTotal(timesheet.Id).ToString("00000.000").Replace(".", ""));
cmd.Parameters.Add("@COMMENT", timesheet.EmployeeComments);
cmd.ExecuteNonQuery();
conn.Close();
}
我似乎无法弄清楚发生了什么或为什么我会收到上述错误。我的连接字符串如下所示:
private const string _CONNSTRING = "DataSource=192.168.50.200;DefaultCollection=QMFILES;Naming=sql;UserID=XXX;Password=XXX;";
可能是库列表问题吗?该程序仅引用库列表中的一个文件。有什么建议吗?
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))
{
conn.Open();
string sqlStatement = "MPRLIB.SIGNTIMESHEET (@SSN, @SIGNATURE, @WORKSTATION, @TOTALHOURS, @COMMENT)";
//string sqlStatement = "MPRLIB.SIGNTIMESHEET (?, ?, ?, ?, ?)";
iDB2Command cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = sqlStatement;
cmd.Parameters.Add("@SSN", timesheet.EmployeeUniqueKey.ToString("0000000000"));
cmd.Parameters.Add("@SIGNATURE", timesheet.EmployeeTypedName);
cmd.Parameters.Add("@WORKSTATION", timesheet.EmployeeSignedComputer);
cmd.Parameters.Add("@TOTALHOURS", GetJobHoursTotal(timesheet.Id).ToString("00000.000").Replace(".", ""));
cmd.Parameters.Add("@COMMENT", timesheet.EmployeeComments);
cmd.ExecuteNonQuery();
conn.Close();
}
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 = "DataSource=192.168.50.200;DefaultCollection=QMFILES;Naming=sql;UserID=XXX;Password=XXX;";
Could it be a library list issue? The program just references one file that is in the library list. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样:
Try like this: