nedcomp hosting homepage

Producten en Diensten
Dedicated servers
Datacenter informatie
Partners, resellers
Helpdesk informatie
Technische docs, tools
Support homepage
ASP componenten
Praktische ASP, ASP.NET
Visual route server
Whois (domein gegevens)
Software documentatie
Whitepapers
Zoeken
Nedcomp / algemeen

Zoeken
 

Copyright © Nedcomp Hosting
Telefoon nr :   +31 184 670111
Fax nummer :   +31 184 631384
E-mailadres :   info@nedcomp.nl
 

.NET Framework Class Library  

SqlGuid Structure

Represents a globally unique identifier to be stored in or retrieved from a database.

For a list of all members of this type, see SqlGuid Members.

System.Object
   System.ValueType
      System.Data.SqlTypes.SqlGuid

[Visual Basic]
Public Structure SqlGuid
   Implements INullable, IComparable
[C#]
public struct SqlGuid : INullable, IComparable
[C++]
public __value struct SqlGuid : public INullable, IComparable

[JScript] In JScript, you can use the structures in the .NET Framework, but you cannot define your own.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Remarks

Guid and SqlGuid implement the CompareTo method differently. SqlGuid implements CompareTo using SQL Server behavior, in which only the last 6 bytes of a value are evaluated. Guid evaluates 16 bytes. This difference in behavior can lead to a discrepancy between how SQL Server and the DataSet perform a sort operation. The following C# example demonstrates this behavioral difference.

using System;
using System.Data.SqlTypes;
using System.Collections;
class Test {
    public static void Main() {
        try {
            ArrayList a = new ArrayList();
            a.Add(new Guid("3AAAAAAA-BBBB-CCCC-DDDD-2EEEEEEEEEEE"));
            a.Add(new Guid("2AAAAAAA-BBBB-CCCC-DDDD-1EEEEEEEEEEE"));
            a.Add(new Guid("1AAAAAAA-BBBB-CCCC-DDDD-3EEEEEEEEEEE"));
            Console.WriteLine("--Unsorted Guids--");
            foreach (Guid g in a) {                
                Console.WriteLine("{0}", g);
            }
            a.Sort();
            Console.WriteLine("--Sorted Guids--");
            foreach (Guid g in a) {
                Console.WriteLine("{0}", g);
            }
            a.Clear();
            a.Add(new SqlGuid("3AAAAAAA-BBBB-CCCC-DDDD-2EEEEEEEEEEE"));
            a.Add(new SqlGuid("2AAAAAAA-BBBB-CCCC-DDDD-1EEEEEEEEEEE"));
            a.Add(new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-3EEEEEEEEEEE"));
            a.Sort();
            Console.WriteLine("--Sorted SqlGuids--");
            foreach (SqlGuid g in a) {
                Console.WriteLine("{0}", g);
            }
        } catch (Exception exc) {
            Console.WriteLine(exc);
        }
    }
}

This example produces the following results.

--Unsorted Guids--
3AAAAAAA-BBBB-CCCC-DDDD-2EEEEEEEEEEE
2AAAAAAA-BBBB-CCCC-DDDD-1EEEEEEEEEEE
1AAAAAAA-BBBB-CCCC-DDDD-3EEEEEEEEEEE
--Sorted Guids--
1AAAAAAA-BBBB-CCCC-DDDD-3EEEEEEEEEEE
2AAAAAAA-BBBB-CCCC-DDDD-1EEEEEEEEEEE
3AAAAAAA-BBBB-CCCC-DDDD-2EEEEEEEEEEE
--Sorted SqlGuids--
2AAAAAAA-BBBB-CCCC-DDDD-1EEEEEEEEEEE
3AAAAAAA-BBBB-CCCC-DDDD-2EEEEEEEEEEE
1AAAAAAA-BBBB-CCCC-DDDD-3EEEEEEEEEEE

Requirements

Namespace: System.Data.SqlTypes

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET

Assembly: System.Data (in System.Data.dll)

See Also

SqlGuid Members | System.Data.SqlTypes Namespace