Scott Selby
Scott Selby

Reputation: 9570

Conversion from type 'Guid' to type 'String' is not valid

I have this code , which is supposed to check if value is nothing

_Attendee.TransactionID = If((a.tGatewayTrxID Is Nothing), Guid.NewGuid(), a.tGatewayTrxID.ToString)

The last part of this code is throwing exception "Conversion from type 'Guid' to type 'String' is not valid." I know that IIF evaluates each part of the statement, If is not supposed to do that. I use this same code all over the place and it always catches null or Nothing values - why is it not working in this case?

Upvotes: 2

Views: 4905

Answers (1)

PeterJ
PeterJ

Reputation: 3794

If TransactionID is a string I believe you just need to change Guid.NewGuid() to Guid.NewGuid().ToString().

Upvotes: 4

Related Questions