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!
kevman123Asked:
Who is Participating?
 
Bob LearnedCommented:
Nope, you can't set the variable.

Bob
0
 
Bob LearnedCommented:
What is the context for this question?  It might be possible to use Guid.Empty, but it is difficult to tell with that description.

Bob
0
 
kevman123Author Commented:
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.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Bob LearnedCommented:
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
0
 
kevman123Author Commented:
Yes, I think we've added some code in that section, but didn't know if we could assign it directly to the variable.
0
 
kevman123Author Commented:
Ok - thanks for the info!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.