create procedure get_count
as
aa number;
begin
select count(*) into aa from student;
end;
/
===========
以上为建立的存储过程,报告过程建立成功OracleConnection myConnection = new OracleConnection(ConfigurationSettings.AppSettings["ConnectionStringSys"]);
myConnection.Open();
OracleCommand command = new OracleCommand("GetCategoryBooks", myConnection);
try
{
         cmd.Connection = myConnection;
cmd.CommandText = "get_count";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("reccount", OracleType.Number);
cmd.Parameters["reccount"].Direction = ParameterDirection.Output;
myConnection.Open();
cmd.ExecuteNonQuery();   //这里就出错,跳到catch中了
myConnection.Close();
myConnection.Dispose();
cmd.Dispose();
}
catch(Exception er)
{
string str = er.ToString();
myConnection.Close();
myConnection.Dispose();
cmd.Dispose();
}

解决方案 »

  1.   

    cs 代码发错了
    OracleConnection myConnection = new OracleConnection(ConfigurationSettings.AppSettings["ConnectionStringSys"]);
    myConnection.Open();
    OracleCommand cmd= new OracleCommand();
    try
    {
             cmd.Connection = myConnection;
    cmd.CommandText = "get_count";
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("reccount", OracleType.Number);
    cmd.Parameters["reccount"].Direction = ParameterDirection.Output;
    myConnection.Open();
    cmd.ExecuteNonQuery();   //这里就出错,跳到catch中了
    myConnection.Close();
    myConnection.Dispose();
    cmd.Dispose();
    }
    catch(Exception er)
    {
    string str = er.ToString();
    myConnection.Close();
    myConnection.Dispose();
    cmd.Dispose();
    }
      

  2.   

    aa number什么啊?
    参数不是这么写的
      

  3.   

    我以前从来没用过存储过程,所以是照着别人写的存储过程写的,表到是用我服务器上有的表oracle也报存储过程建立正确了,郁闷 还真不是很清楚aa是什么呢有没有建立一个简单存储过程,然后用.net取结果数值的例子?多谢了
      

  4.   

    http://www.microsoft.com/china/MSDN/library/data/dataAccess/DMSDNorsps.mspx
      

  5.   

    呵呵,你不觉得很眼熟么?我就是用的它啊不过它是针对oracle 9i的~ 我现在的数据库是oracle 816