dave <dy@onlinelg.com> wrote:
while adding paramters for a stored procedure i have the
following line
arParams[2] = new SqlParameter("@TopicID", (TopicID==-1)?
System.DBNull.Value:TopicID);
this does not compile with the following error
"Type of conditional expression can't be determined
because there is no implicit conversion
between 'System.DBNull' and 'int'"
How best can I fix this (besides the long for if/else
format)?
Cast both expressions to the type you want, eg
arParams[2] = new SqlParameter ("@TopicID", (TopicID==-1) ?
(object)DBNull.Value : (object)TopicID);
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too