使用存储过程并获取一个返回值

SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
            SqlCommand comm = conn.CreateCommand();
            conn.Open();
            comm.CommandType = CommandType.StoredProcedure;
            comm.CommandText = "GET";
            SqlParameter par = new SqlParameter("@get", 3);
            comm.Parameters.Add(par);
            comm.Parameters[0].Direction = ParameterDirection.Output;
            comm.ExecuteReader();
            ViewData["d"] = comm.Parameters["@get"].Value.ToString();
            conn.Dispose();

你可能感兴趣的:(职场,存储,休闲)