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