GUID and uniqueidentifier

  • Thread starter Thread starter Carl
  • Start date Start date
C

Carl

Hi,

I do have one dataset from SQL server with a field
(bound) to Textbox called txtID , this field is of type
uniqueidentifier.

From the doc, they say the equivalent is GUID in dot net,

UniqueIdentifier = Supported by the .NET Compact
Framework. =
Guid = A globally unique identifier (or GUID).

Now, when that field is display into the form, I can see
the actual value without any issue.

My trouble is how can I pas it back to one function to be
use for update.

I try to cast it to GUID with the following syntax,
(System.Guid)txtID.Text

But receive the error Cannot convert type 'string'
to 'System.Guid'

So, how do I convert this txtID Textbox into GUID or
uniqueidentifier ?

Carl,
 
Instead of using a cast, call the Guid constructor, e.g.

Guid g = new Guid(txtID.text)
 
Back
Top