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();
}
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();
}
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();
}
参数不是这么写的