Tina's blog
开心过好每一天! Come on !

 public static SqlParameter MakeParam(string ParamName, SqlDbType DbType, Int32 Size, ParameterDirection Direction, object Value)
    {
        SqlParameter param;

        if (Size > 0)
            param = new SqlParameter(ParamName, DbType, Size);
        else
            param = new SqlParameter(ParamName, DbType);

        param.Direction = Direction;
       if (!((Direction == ParameterDirection.Output || Direction == ParameterDirection.ReturnValue) && Value == null))
        {
            param.Value = Value;
        }
        return param;
    }

 

2.使用:

 SqlParameter[] sqlPrm ={
            new SqlParameter("@MemberID", userID),
            new SqlParameter("@subject", subject),
            new SqlParameter("@note", note),
            new SqlParameter("@duration", duration),

            Util.MakeParam("@NewAppID", SqlDbType.Int, 4,ParameterDirection.Output,null)
        };

3.当执行完sql语句后可以通过

       newAppID = sqlPrm[4].Value.ToString();

    获得数据库里面通过改变后的值

posted on 2008-08-12 16:05  Tinachang  阅读(229)  评论(0编辑  收藏  举报