asp.net中调用oracle 9i中的存储过程的请教
下面这段代码是我在Oracle 9i的方案下的enshi2004用户下根据向导定义的
(
p_id in number
)
as
begin
declare x number(30);
begin
select count(*) into x from enshi2004.cgfgxx where id = p_id;
if x > 0 then
insert into enshi2004.testclob values (555,'ft','hehe');
else
insert into enshi2004.testclob values (999,'ft','hehe');
end if;
end;
end usp_test;
我在一个测试页面中使用的代码如下:
String strConnect = System.Configuration.ConfigurationSettings.AppSettings["strConnectDB"].ToString(); //这条
语句是从web.config中取得连接字符串
OracleConnection oraConn = new OracleConnection(strConnect);
OracleCommand myCommand = new OracleCommand("enshi2004.usp_test",oraConn);
//其中enshi2004是我的一个用户名,我所使用的表和存储过程都是这个用户的。usp_test是存储过程名。见上。
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add("@p_id",245);
oraConn.Open();
myCommand.ExecuteNonQuery();
//每次总是这里出错,好像是调用存储过程出现的问题
oraConn.Close();
Response.Write("Success!");
提示错误如下:
ORA-01036: 非法的变量名/编号
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OracleClient.OracleException: ORA-01036: 非法的变量名/编号
源错误:
行 34: myCommand.Parameters.Add("@p_id",245);
行 35: oraConn.Open();
行 36: myCommand.ExecuteNonQuery();行 37: //每次总是这里出错,
好像是调用存储过程出现的问题
行 38:
源文件: d:\保留\enshi\kjcgxx\testusp.aspx.cs 行: 36
请大虾指教!
谢谢!