Is there a better/cleaner way to do this?
int stockvalue = 0;
if (!Convert.IsDBNull(reader[\"StockValue\"]))
stockvalue = (int)reader[\"StockValue\"];
>
int? stockvalue = (int?)(!Convert.IsDBNull(result) ? result : null);
One possible solution so that you ensure that the DBNull carries across to your code. For our group, as a best practice, we try and not allow NULL columns in the database unless its really needed. There is more overhead in coding to handle it, and sometimes just rethinking the problem makes it so its not required.