J
Jim Heavey
Trying to figure out how to use the ? operator. It looked simple enough,
but of course it is never that way for me.
I am create a Parameter. One of the parameters my contain DBNull.value or
a string value. I set up the following senario....
string dbOwner = _dbOwner; // could have a value or a 0 length
I have my own method for creating a parameter. If I place DBNull.value in
this method, it works just fine. Likewise, if I place an actual string in
this field (5th parameter) it works just fine
CreateDataParameter(_internalCmd,"@procedure_owner",
SqlDbType.NVarChar,
384,
((dbOwner.Length > 0) ? dbOwner: DBNull.Value),
DBUtility.ParameterDir.Input,
true);
I get the following compile error - "No implicit conversion between string
and System.DbNull.
Maybe the problem is not with the ? at all, maybe the compiler is
complaining about two defferent types, but it would seem that it would have
complained about this without the expression and just having DBNull.Value,
but it does not complain.
Any idea how to overcome?
but of course it is never that way for me.
I am create a Parameter. One of the parameters my contain DBNull.value or
a string value. I set up the following senario....
string dbOwner = _dbOwner; // could have a value or a 0 length
I have my own method for creating a parameter. If I place DBNull.value in
this method, it works just fine. Likewise, if I place an actual string in
this field (5th parameter) it works just fine
CreateDataParameter(_internalCmd,"@procedure_owner",
SqlDbType.NVarChar,
384,
((dbOwner.Length > 0) ? dbOwner: DBNull.Value),
DBUtility.ParameterDir.Input,
true);
I get the following compile error - "No implicit conversion between string
and System.DbNull.
Maybe the problem is not with the ? at all, maybe the compiler is
complaining about two defferent types, but it would seem that it would have
complained about this without the expression and just having DBNull.Value,
but it does not complain.
Any idea how to overcome?