kevman123
asked on
Setting GUID value to NULL
How do I set a GUID to NULL? When I try, I get an error saying Can't convert type System.DBNull to System.GUID.
Also, we can't use Nullable(of GUID) types.
Thanks!
Also, we can't use Nullable(of GUID) types.
Thanks!
ASKER
For example:
Dim testGUID as GUID
testGUID = DBNull.Value
<error>
We need to save null values to the database because of foreign key requirements. If I use Guid.Empty it puts all zeros. I think the only way to handle it is to capture it on the save back to the database.
Dim testGUID as GUID
testGUID = DBNull.Value
<error>
We need to save null values to the database because of foreign key requirements. If I use Guid.Empty it puts all zeros. I think the only way to handle it is to capture it on the save back to the database.
Since you aren't using a nullable GUID type, then you are going to have to process that somewhere else, since you can't set a GUID to DBNull.
Are you using a stored procedure to write to the database?
Bob
Are you using a stored procedure to write to the database?
Bob
ASKER
Yes, I think we've added some code in that section, but didn't know if we could assign it directly to the variable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok - thanks for the info!
Bob