Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Nullable GUIDs

Posted on 2008-10-17
6
Medium Priority
?
2,675 Views
Last Modified: 2013-11-07
n 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 say myNewRow.myGuidColumn = myGuid I get the following error: "Cannot implicitly convert type 'System.Guid?' to 'System.Guid'."
0
Comment
Question by:iulianchira
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 6

Expert Comment

by:divyeshhdoshi
ID: 22738708
please use guidcolumn= system.Guid.NewGuid()
0
 

Author Comment

by:iulianchira
ID: 22738754
I do not want to a new GUID, i allready have the GUID I want to insert.
0
 
LVL 6

Expert Comment

by:divyeshhdoshi
ID: 22738775
but in whatever guid it should have some value.
otherwise it will insert null in guid column.

like You have created a guid
System.Guid g=System.Guid.NewGuid()

you can not use this one
System.Guid g=new System.Guid() will create guid with blank.

0
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 

Author Comment

by:iulianchira
ID: 22738785
I want to have null sometimes in the column.
0
 
LVL 6

Accepted Solution

by:
openshac earned 2000 total points
ID: 22738791
Guid? and Guid are different types.
you need to cast the nullable guid before assigning it to a guid value:
myNonNullableGuid = (Guid)myNullableGuid;

Open in new window

0
 
LVL 6

Expert Comment

by:openshac
ID: 22738803
or in your case
myNewRow.myGuidColumn = (Guid)myGuid ;

Open in new window

0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question