In my database, in one of the table I have a GUID column with allow nulls. I have a method with a Guid? parameter that inserts a new data row in the table. However when I s
OK; how is myGuidColumn defined, and how is myGuid defined?
If myGuid is Guid?
and myGuidColumn is Guid
, then the error is correct: you will need to use myGuid.Value
, or (Guid)myGuid
to get the value (which will throw if it is null), or perhaps myGuid.GetValueOrDefault()
to return the zero guid if null.
If myGuid is Guid
and myGuidColumn is Guid?
, then it should work.
If myGuidColumn is object
, you probably need DBNull.Value
instead of the regular null.
Of course, if the column is truly nullable, you might simply want to ensure that it is Guid?
in the C# code ;-p