public static void AddPparameter(string name, object value, param_types type) { param = new SqlParameter(name, value); switch (type) { case param_types.Int: param.SqlDbType = SqlDbType.Int; break; case param_types.BigInt: param.SqlDbType = SqlDbType.BigInt; break; case param_types.Varchar: param.SqlDbType = SqlDbType.VarChar; break; case param_types.NVarchar: param.SqlDbType = SqlDbType.NVarChar; break; case param_types.Date: param.SqlDbType = SqlDbType.Date; break; case param_types.DateTime: param.SqlDbType = SqlDbType.DateTime; break; case param_types.Image: param.SqlDbType = SqlDbType.Image; break; case param_types.Structured: param.SqlDbType = SqlDbType.Structured; break; case param_types.Text: param.SqlDbType = SqlDbType.Text; break; default: param.SqlDbType = SqlDbType.VarChar; break; } cmd.Parameters.Add(param); }
public static void AddPparameter(string name, object value, param_types type, int size, param_direction direction) { param = new SqlParameter(name, value); switch (type) { case param_types.Int: param.SqlDbType = SqlDbType.Int; break; case param_types.BigInt: param.SqlDbType = SqlDbType.BigInt; break; case param_types.Varchar: param.SqlDbType = SqlDbType.VarChar; break; case param_types.Date: param.SqlDbType = SqlDbType.Date; break; case param_types.DateTime: param.SqlDbType = SqlDbType.DateTime; break; case param_types.Image: param.SqlDbType = SqlDbType.Image; break; case param_types.Structured: param.SqlDbType = SqlDbType.Structured; break; case param_types.Text: param.SqlDbType = SqlDbType.Text; break; case param_types.Numeric: param.SqlDbType = SqlDbType.Decimal; break; default: param.SqlDbType = SqlDbType.VarChar; break; } if (direction == param_direction.Output) { param.Direction = ParameterDirection.Output; } param.Size = size; cmd.Parameters.Add(param); }