zoukankan      html  css  js  c++  java
  • Asp.Net中调用存储过程并返回输出参数

     1  /// <summary>
     2         /// 调用存储过程返回参数
     3         /// </summary>
     4         /// <param name="orderId"></param>
     5         /// <param name="cancelOrderReson"></param>
     6         /// <returns></returns>
     7         private string[] CancelOrderProcedure(int orderId, string cancelOrderReson)
     8         {
     9             string constr = DbHelperSQL.connectionString;
    10             SqlConnection conn = new SqlConnection(constr);
    11             conn.Open();
    12             SqlCommand cmd = new SqlCommand();
    13             cmd.Connection = conn;
    14             cmd.CommandText = "Remy_Customer_CancelRedeemOrder";
    15             cmd.CommandType = CommandType.StoredProcedure;
    16             //参数一
    17             SqlParameter parameter_OrderId = new SqlParameter("@RedeemOrderId", SqlDbType.Int);
    18             parameter_OrderId.Direction = ParameterDirection.Input;
    19             parameter_OrderId.Value = orderId;
    20             //参数二
    21             SqlParameter parameter_OrderRemind = new SqlParameter("@RedeemOrderRemind", SqlDbType.NVarChar, 50);
    22             parameter_OrderRemind.Direction = ParameterDirection.Input;
    23             parameter_OrderRemind.Value = cancelOrderReson;
    24 
    25             SqlParameter parameter_ReturnCode = new SqlParameter("@ReturnCode", SqlDbType.NVarChar, 50);
    26             parameter_ReturnCode.Direction = ParameterDirection.Output;
    27             parameter_ReturnCode.Value = "";
    28             SqlParameter parameter_ReturnReason = new SqlParameter("@ReturnReason", SqlDbType.NVarChar, 200);
    29             parameter_ReturnReason.Direction = ParameterDirection.Output;
    30             parameter_ReturnReason.Value = "";
    31 
    32             cmd.Parameters.Add(parameter_OrderId);
    33             cmd.Parameters.Add(parameter_OrderRemind);
    34 
    35             cmd.Parameters.Add(parameter_ReturnCode);
    36             cmd.Parameters.Add(parameter_ReturnReason);
    37             try
    38             {
    39                 cmd.ExecuteNonQuery();
    40             }
    41             finally
    42             {
    43                 conn.Close();
    44             }
    45             string[] cancelResult = new String[2] { parameter_ReturnCode.Value.ToString(), parameter_ReturnReason.Value.ToString() };
    46             return cancelResult;
    47         }
  • 相关阅读:
    Unknown type name 'class'; did you mean 'Class'? 问题的解决
    pxe+kickstart无人值守批量安装linux
    从图片中的一点取色
    结合UIImageView实现图片的移动和缩放
    把UIColor对象转化成UIImage对象
    iPhone:constrainedToSize获取字符串的宽高 自定义label的高度和宽度
    UITextField详解
    Iphone通过viewDidLoad设置拉伸图像与按钮样式
    iPhone 利用CG API画一个饼图(Pie chart)
    UILabel详解
  • 原文地址:https://www.cnblogs.com/luoyangcn/p/4223976.html
Copyright © 2011-2022 走看看