Converting GUID to a string

  • Thread starter Thread starter Dave Thomas
  • Start date Start date
D

Dave Thomas

I am using SQL CE where I have a GUID type field in one table. I am
generating new records on the Pocket PC and trying to update the server with
the GUID field. Where it really gets fuzzy is when I have an array element
( typed as System.Guid ) with valid data. The problem is that I get an
'InvalidCastException' when using the following syntax:

mystr = aUploadArray(iCheckArray).tUID.ToString("D") .

Now if I debug the session and do a quick watch on
aUploadArray(iCheckArray).tUID.ToString("D") it returns the valid guid with
type string . It's probably just a CFquirk, but has anyone seen this before?


TIA,

Dave

PS What if the Hokey Pokey IS what it's all about?
 
And mystr as defined as what?
In general, if you have a field of type "uniqueidentifier", it is
represented by SqlCeDataReader as Guid type and the corresponding
SqlCeCommand parameter will accept Guid type for its value. There is no need
to do string conversion; in fact it will adversely affect performance
 
Alex,
That worked wonderfully. I had to re-tool a little but ended up
learning a few things in the process. Thanks for the help!

PS I had to declare a System.guid variable and pass the contents of the
SQLCE guid field to it. Then the parameter value was happy with it.


Cheers,

Dave Thomas (not the Wendy's guy)
 
Back
Top