zoukankan      html  css  js  c++  java
  • c# 执行调用Oracle Procedure传参及回传值

    ////定義參數
                   //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();

  • 相关阅读:
    java.lang.IllegalArgumentException: Not an managed type
    时间 日期 转换
    纯JavaScript开发飞机大战项目
    【thinkPHP框架】Failed opening required 'header.php' include_path='.;c:php5pear 终级解决方案
    【精编重制版】JavaWeb 入门级项目实战 -- 文章发布系统 (第二节)
    【PHP快速入门】 第二节 php基本语法
    【精编重制版】JavaWeb 入门级项目实战 -- 文章发布系统 (第一节)
    个人博客恢复访问
    【H5 音乐播放实例】第一节 音乐详情页制作(1)
    【php增删改查实例】第二十六节
  • 原文地址:https://www.cnblogs.com/popo1/p/11613596.html
Copyright © 2011-2022 走看看