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

                  }

  • 相关阅读:
    Linux环境下安装Tigase XMPP Server
    虚拟机几种网络连接方式的区别
    MySQL修改root密码
    Eclipse使用多个Console
    Eclipse导入Java项目时“No projects are found to import”错误的处理
    GitHub上下载源代码的方法
    Tigase XMPP Server的安装
    MySQL的安装与配置
    Windows下查看JDK是否安装以及安装路径
    archive for required library...
  • 原文地址:https://www.cnblogs.com/Trafalgar/p/5662779.html
Copyright © 2011-2022 走看看