I am trying to pass null value to SqlParameter if the value of variable vName is null, else pass vName value as shown below
cmd.Parameters.Add(new SqlParameter("@NAME", SqlDbType.VarChar)).Value = vName ? null : DBNull.Value;
but I get an error
Cannot implicitly convert type 'string' to 'bool'
I searched and found that I have to use AgeItem.AgeIndex but I got error that says
The name 'AgeItem' does not exist in the current context
cmd.Parameters.Add(new SqlParameter("@NAME", SqlDbType.VarChar)).Value =(object)AgeItem.AgeIndex ?? DBNull.Value;