Dealing with GUID values in SQL Server CE

A GUID (Globally Unique IDentifier) is a 16-byte unique number generated by the system that is guaranteed to be globally unique. It is commonly used to uniquely identify records. As you will be using GUIDs frequently in your sales force application, you need to know how they will be stored in the database.

SQL Server CE and Oracle Lite handles GUID storage differently. SQL Server CE can store a guid using the uniqueidentifier data type. This data type is directly compatible with the .NET Compact Framework System.Guid object. This means that explicit conversion of data types is not required when reading from or writing to a

UNIQUEIDENTIFIER column.

As you've read earlier, the GUiDToNative() and NativeToGUiD() methods defined in the iDataLibPlugin interface are used to convert the .NET Compact Framework System.Guid object to the native format used by the database to store GUID values, and vice versa.

As no explicit conversion is necessary, we can simply return the objects in the same form as they are passed in:

public object GUIDToNative(System.Guid AccountGUID) {

return AccountGUID;

public System.Guid NativeToGUID(object AccountGUID) {

return (System.Guid)AccountGUID;

Was this article helpful?

0 0

Post a comment