1.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("@appID", appID),
new SqlParameter("@Type", type),
new SqlParameter("@Name", name),
Util.MakeParam("@IsDuplicate",SqlDbType.Bit,1,ParameterDirection.Output,null)
};