Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting SQL Server uniqueidentifier to .NET Guid type
Message
From
24/03/2009 12:33:43
 
 
To
24/03/2009 10:35:28
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 3.0
Database:
MS SQL Server
Miscellaneous
Thread ID:
01391015
Message ID:
01391063
Views:
54
I'm also curious about wich one is recommanded. FWIW, I use a variant of the first version (wich I find shorter):
Guid UserId = new Guid(reader["UserId"].ToString());
>Hopefully somebody can provide a better way of doing this. The UserId field in my datareader is uniqueidentifier type in SQL Server.
>Guid UserId = new Guid(Convert.ToString(reader["UserId"]));
>Would this be better (more efficent):
>Guid UserId  = (Guid) reader["UserId"];
>Overall, is it better to use the System.Convert method or do a cast like the second example?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform