zoukankan      html  css  js  c++  java
  • c#中获取存储过程的返回值(return Value)

                  string connStr = "server=kofo;database=pubs;uid=sa;pwd=kofo123";

                  SqlConnection myConnection = new SqlConnection(connStr);

                  try

                  {

                       myConnection.Open();

                       SqlCommand myCommand = new SqlCommand("TestRetValue",myConnection);

                       myCommand.CommandType = CommandType.StoredProcedure;

                       SqlParameter myParam = myCommand.Parameters.Add(new SqlParameter("@RETURN_VALUE",SqlDbType.Int,4));                

                       myParam.Direction = ParameterDirection.ReturnValue;             

                       myCommand.ExecuteNonQuery();

                       int me = (int)myParam.Value;

                       MessageBox.Show(me.ToString());

                      

                  }

                  catch(Exception ex)

                  {

                       MessageBox.Show(ex.Message);

                  }

                  finally

                  {

                       myConnection.Close();

                  }

  • 相关阅读:
    jdbc(插入大对象及读取大对象、存储过程)
    jdbc批量插入操作(addBatch)
    javase(Properties集合及学生对象信息录入文本中案例)
    javase模拟斗地主洗牌和发牌(54)
    javase套接字编程
    javase网络编程
    javase多线程复制
    javase文件切割及融合
    设计原则
    模板方法模式
  • 原文地址:https://www.cnblogs.com/Trafalgar/p/5662779.html
Copyright © 2011-2022 走看看