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

查看:114
本文介绍了如何使用C#通过oracle和.aspx传递输入参数和输出参数存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am writing store procedure in .net application with oracle data base. while executing am getting below error. Please any one help on this issue, actually i do not have much idea about store procedure, Please any one help on... thank you for advance

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





代码:





code :

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"的字符串.

首先检查它们,看看是否有简单的类型问题.
Without your stored procedure text, it is difficult to tell exactly, but the error message is pretty explicit: "wrong number or types of arguments" - so either your procedure does not have arguments, or they are not an integer called "@empno" and a string called "empname"

Check them first, and see if you have a simple type problem.


确保存储过程中有两个具有相同类型的参数.
传递给SP的参数数量和期望的数量很可能出错.
Make sure you have two parameters with the same types in your stored procedure.
It is mostly likely that there is an error with the number of parameters being passed to the SP and the number it expects.


这篇关于如何使用C#通过oracle和.aspx传递输入参数和输出参数存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆