码迷,mamicode.com
首页 > 数据库 > 详细

c# 执行调用Oracle Procedure传参及回传值

时间:2019-09-30 18:12:20      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:ada   table   varchar2   text   连接   direct   dir   tor   tap   

////定義參數
               //IDataParameter[] parameters =
               //             {
               //                 new OracleParameter(":p_stage", OracleDbType.Varchar2,model.Stage, ParameterDirection.Input),//传值
               //                  new OracleParameter(":ReturnValue", OracleDbType.Varchar2, ParameterDirection.Output)//回传
               //             };

               ////參數賦值
               ////parameters[0].Value = model.Stage;
               //string prconn = System.Configuration.ConfigurationManager.AppSettings["DBConnStr_tnboa1insert"];
               //OracleConnection conn = new OracleConnection(prconn);
               //conn.Open();
               //OracleCommand cmd = new OracleCommand("PRO__SETTLEMENT", conn);  //Procedure &连接数据库
               //cmd.CommandType = CommandType.StoredProcedure;
               //cmd.Parameters.AddRange(parameters);
               //OracleDataAdapter oda = new OracleDataAdapter(cmd);
               //DataTable dt = new DataTable();
               //oda.Fill(dt);
               //conn.Close();
               //string iReturn = cmd.Parameters["RETURNVALUE"].Value.ToString();
               ////return ds.Tables[0];

              // string iReturn = ConnInstance.ExecuteQuery_Sp("PRO_SETTLEMENT", parameters);//执行完成后得到回传的结果



               DataTable dt = new DataTable();
               string prconn = System.Configuration.ConfigurationManager.AppSettings["DBConnStr_tnboa1insert"];
               OracleConnection conn = new OracleConnection(prconn);
               conn.Open();
               OracleCommand cmd = new OracleCommand("PRO_SETTLEMENT",conn);  //Procedure&连接数据库
               //cmd.CommandText = "PRO_SETTLEMENT";  //Procedure

               cmd.CommandType = CommandType.StoredProcedure;

               cmd.Parameters.Add("P_STAGE", OracleDbType.Varchar2).Direction = ParameterDirection.Input;//传值类型定义
                cmd.Parameters["P_STAGE"].Value = model.Stage;//赋值
                cmd.Parameters.Add("RETURNVALUE", OracleDbType.Varchar2,200).Direction = ParameterDirection.Output;//回传  注:回传定义字符长度,忽略会报错

                cmd.ExecuteNonQuery();
                string iReturn = cmd.Parameters["ReturnValue"].Value.ToString();////执行完成后得到回传的结果
                conn.Close();

c# 执行调用Oracle Procedure传参及回传值

标签:ada   table   varchar2   text   连接   direct   dir   tor   tap   

原文地址:https://www.cnblogs.com/popo1/p/11613596.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!