如何通过输入参数和输出参数的存储过程uing oracle和.aspx与c#。[英] how to pass input parameters and output parameters store procedure uing oracle and .aspx with c#

问题描述

我正在使用 oracle 数据库.net 应用程序中编写存储过程.执行时出现错误.请任何人帮助解决这个问题,实际上我对存储程序不太了解,请任何人帮助...谢谢您的提前

errors : ORA-06550: line 1, column 7:<br />
PLS-00306: wrong number or types of arguments in call to ''EMPLOYEE_NAME''<br />
ORA-06550: line 1, column 7:<br />
PL/SQL: Statement ignored




代码:
public void SMSAlertFunction(int id,string firstname)
     {
        try
        {
            DataTable dt = new DataTable();
            //log4net.Config.XmlConfigurator.Configure();
            //log.Info("SMSAlertFunction has been called...." + Message.ToString());
            //OleDbConnection service_db = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["CallinglistDBROI"].ToString());
            OleDbConnection service_db = new OleDbConnection("Provider=MSDAORA.1;Password=genesys;User ID=IVR_APP;Data Source=CONFIG_10.5.17.190;Persist Security Info=True;");
            //log.Info("Data Base Details :" + service_db);
            service_db.Open();
            OleDbParameter olepar = new OleDbParameter();
            OleDbCommand olecmd = new OleDbCommand();
            olecmd.Connection = service_db;
            olecmd.CommandType = CommandType.StoredProcedure;
            olecmd.CommandText = "EMPLOYEE_NAME";
            olepar = olecmd.Parameters.Add("@empno", OleDbType.Integer);
            olepar.Value = id;
            olepar = olecmd.Parameters.Add("empname", OleDbType.VarChar);
            olepar.Value = firstname;
            olecmd.ExecuteNonQuery();
            OleDbDataAdapter da = new OleDbDataAdapter(olecmd);
            da.Fill(dt);
            service_db.Close();


        }
        catch (Exception ex)
        {
            //log.Error("Error at SMSAlertFunction.... " + ex.ToString());

        }
    }

推荐答案

没有您的存储过程文本,很难准确判断,但错误消息非常明确:"参数数量或类型错误" -所以要么你的过程没有参数,要么它们不是一个名为"@empno"的整数和一个名为"empname"的字符串

先检查一下,看看是否有简单的类型问题.

确保存储过程中有两个类型相同的参数.
很可能是传递给 SP 的参数数量和它期望的数量有错误.

本文地址:https://www.itbaoku.cn/post/1394879.html