Casting to System.Guid

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

ASP.NET 2.0

In the code below, the reader has a column named "Id". The MsgInfo class
needs that value sent into its constructor. But MsgInfo need it as a
System.Guid datatype. How do I convert this "Id" value to System.Guid
datatype??

protected virtual MsgInfo ReadMessage(IDataReader reader)
{
return new MsgInfo(System.Guid(reader["Id"]) <.---- this code crashes
because this is not the correct way of converting
}

Any suggestions

Jeff
 
If the id column does indeed contain data of type Guid then you can try this:
new System.Guid(reader["Id"].ToString()) to convert the reader's ID column
value into a guid.

HTH,

_______________________
MSc Konstantinos Pantos
[ASP.NET MVP]
http://kostas.pantos.name
 
Back
Top