M
Mark Rae
Hi,
In v1.x, the following code worked perfectly:
mobjSqlParameter.Value = strPayerBusinessName == null ? strPayerBusinessName
: (object)DBNull.Value;
However, I can't get it to work in v2. I know that the value of
strPayerBusinessName is null because if I write
strPayerBusinessName == null in the Immediate Window, it returns "true".
However, the expression does not seem to evaluate the right-hand side, no
matter what I write. E.g., the following code
mobjSqlParameter.Value = strPayerBusinessName == null ? strPayerBusinessName
: "Hello";
does not populate mobjSqlParameter.Value with the string "Hello" when
strPayerBusinessName is null.
Has this syntax been deprecated in v2?
I realise, of course, that I can write:
if(strPayerBusinessName == null)
{
mobjSqlParameter.Value = DBNull.Value;
}
else
{
mobjSqlParameter.Value = strPayerBusinessName;
}
but I'm curious as to why the ? : syntax doesn't seem to work any more.
Any assistance gratefully received.
Mark
In v1.x, the following code worked perfectly:
mobjSqlParameter.Value = strPayerBusinessName == null ? strPayerBusinessName
: (object)DBNull.Value;
However, I can't get it to work in v2. I know that the value of
strPayerBusinessName is null because if I write
strPayerBusinessName == null in the Immediate Window, it returns "true".
However, the expression does not seem to evaluate the right-hand side, no
matter what I write. E.g., the following code
mobjSqlParameter.Value = strPayerBusinessName == null ? strPayerBusinessName
: "Hello";
does not populate mobjSqlParameter.Value with the string "Hello" when
strPayerBusinessName is null.
Has this syntax been deprecated in v2?
I realise, of course, that I can write:
if(strPayerBusinessName == null)
{
mobjSqlParameter.Value = DBNull.Value;
}
else
{
mobjSqlParameter.Value = strPayerBusinessName;
}
but I'm curious as to why the ? : syntax doesn't seem to work any more.
Any assistance gratefully received.
Mark