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();

                  }

  • 相关阅读:
    1-29反射
    1-28Map简介
    1-27TreeSet简介
    1-26HashSet简介
    1-25泛型
    1-24List三个子类的特点
    1-23集合概述
    Java接口
    1-22日期类型
    简易计算器的实现
  • 原文地址:https://www.cnblogs.com/Trafalgar/p/5662779.html
Copyright © 2011-2022 走看看