Solved

Nullable GUIDs

Posted on 2008-10-17
6
2,630 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
  • 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

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

Accepted Solution

by:
openshac earned 500 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Formula for calculating ROI on training 6 50
table joins in qry 17 63
SSIS Start 2 21
Trouble with <> 2 21
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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