Last post Sep 19, 2014 02:47 PM by Siva Krishna Macha
Sep 19, 2014 01:38 PM|rds80|LINK
How come this works?
loParam.Value = DBNull.Value;
loParam.Value = smeID;
But this doesn't
loParam.Value = string.IsNullOrEmpty(smeID) == true ? DBNull.Value : smeID;
The latter gives the following error:
Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DBNull' and 'string'
Thanks for the help
Sep 19, 2014 01:42 PM|Siva Krishna Macha|LINK
= string.IsNullOrEmpty(smeID) == true ?
The above ternary operator gets confused with the datatype. So, we need to convert it to help it to identify the type.
Sep 19, 2014 01:45 PM|rds80|LINK
Tried that as well. Same error
Sep 19, 2014 01:46 PM|Siva Krishna Macha|LINK
I was parallely editing, did you try with (object) ?
Sep 19, 2014 01:51 PM|rds80|LINK
That worked. Thanks.
I tried explicitly casting the DBNull.Value to a (string). But it gave the same error.
Sep 19, 2014 01:53 PM|Siva Krishna Macha|LINK
Ok, No problem. As the DBparameter.Value expects the type as object, the above statement will expect to cast to object.
Sep 19, 2014 02:06 PM|rds80|LINK
Thanks for the explaination.
Sep 19, 2014 02:47 PM|Siva Krishna Macha|LINK
You're welcome, Have a nice day