I am having trouble SELECTing a column of type uniqueidentifier and putting it in a variable of type Guid in ASP.net.
The database is generating the uniqueidentifier, and all I want to do is pull them out and store the values in case I need to populate a foreign key table.
I am using a private member to store the value:
Private _uniqueID as guid
I SELECT from the table and use a SqlDataReader called vRdr. All the other values are coming out just fine, but when I add this I get an error:
if not isDBNull( vRdr("uniqueID")) then
_uniqueID = vRdr.GetGuid("uniqueID")
end if
The error I get is
Input string was not in a correct format.
I am not sure why I am having so much trouble trying to select these values. I have also tried Guid.Parse() and Guid.TryParse() on the data reader value with no luck.
Thanks for reading.
According to the MSDN docs, GetGuid() takes a column ordinal, not a string key. Change your code to this: