您的位置:首页 > 编程语言 > PHP开发

得到存储过程参数为output的参数值

2008-03-10 11:48 176 查看
 public void bind()
    {
        SqlConnection con = new SqlConnection(strCon);
        con.Open();
        SqlCommand com = new SqlCommand();
        com.CommandType = CommandType.StoredProcedure;
        com.CommandText = "系统管理.USP流水单号By生成";
        com.Connection = con;
        com.Parameters.Add("@流程编码", SqlDbType.VarChar, 7);
        com.Parameters["@流程编码"].Value = "ZDL";
        com.Parameters.Add("@新申请单号", SqlDbType.VarChar, 20);
        com.Parameters["@新申请单号"].Direction = ParameterDirection.Output;

        SqlDataReader dr = com.ExecuteReader();

        //foreach(SqlParameter parmeter in com.Parameters)
        //{
        //    Response.Write(string.Format("参数名:{0},参数方向:{1},参数值:{2}
", parmeter.ParameterName, parmeter.Direction.ToString(), parmeter.Value));
        //}

        for (int i = 0; i < com.Parameters.Count;i++ )
        {
            Response.Write(string.Format("参数名:{0},参数方向:{1},参数值:{2}
", com.Parameters[i].ParameterName, com.Parameters[i].Direction.ToString(), com.Parameters[i].Value));
        }
       
    }

 

//例子:

if (!Page.IsPostBack)
        {
            string 单号 = "1";
           string 流程编码 = "SQ0607";
           Get生成申请单号(流程编码, ref 单号);

        }

 #region 生成申请单号

    /// <summary>
    /// 自动生成申请单号
    /// </summary>
    /// <param name="pFirstCode">前缀代号 (内服药:NFFH 外用药:WYFH)</param>
    /// <param name="pPosition">申请单号</param>

    public  void Get生成申请单号(string 流程编码, ref string 申请单号)
    {
        SqlConnection connection = new SqlConnection(strConnction);
        connection.Open();
        SqlCommand com = new SqlCommand();
        com.Connection = connection;
        com.CommandType = CommandType.StoredProcedure;
        com.CommandText = "系统管理.USP流水单号By生成";
        com.Parameters.Add("@流程编码", SqlDbType.VarChar, 7);
        com.Parameters.Add("@新申请单号", SqlDbType.VarChar, 20);
        com.Parameters[0].Value = 流程编码;
        com.Parameters[1].Direction = ParameterDirection.Output;
        SqlDataReader datReader = com.ExecuteReader();
        申请单号 = com.Parameters[1].Value.ToString();

    }

    #endregion

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  output 存储 string