Casting to System.Guid

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
 
K

Konstantinos Pantos

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top