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

              }


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/mane_yao/archive/2010/04/22/5514181.aspx

相关文章:

  • 2022-01-09
猜你喜欢
  • 2022-02-13
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2021-09-16
  • 2022-01-01
相关资源
相似解决方案