Responder Developer Guide
Compare Method (DbCompare)


Version: 10.2.1a

Resource Center Home

First value to compare.
Second value to compare.
Compares two values and returns a value indicating whether one is less than, equal to or greater than the other in a type-agnotic and null/DBNull aware manner.
Syntax
'Declaration
 
Public Shared Function Compare( _
   ByVal x As Object, _
   ByVal y As Object _
) As Integer
'Usage
 
Dim x As Object
Dim y As Object
Dim value As Integer
 
value = DbCompare.Compare(x, y)
public static int Compare( 
   object x,
   object y
)

Parameters

x
First value to compare.
y
Second value to compare.

Return Value

Values Conditions
Less than 0 x < y
Zero x == y
Greater than 1 x > y
Remarks

The values are converted into equivalent types before the comparison so that the result is type-agnostic (in this context we mean that the values of different types as not considered different just because of their type):

DbCompare.Compare((int)1, (decimal)1); // returns 0; DbCompare.Compare((int)1, "1"); // returns 0; DbCompare.Compare(true, "true"); // returns 0;

In order to use this function correctly it is important to understand its handling of null and DBNull. The following are some assumptions made by the Compare function and therefore the more specialized functions that are based upon it:

Requirements

Target Platforms: Windows XP SP3 (32-bit and 64-bit), Windows 7 (32-bit and 64-bit)

Not all Operating Systems are supported on all products. Visit the ArcFM Solution Supported Versions page for full details.

See Also

Reference

DbCompare Class
DbCompare Members
DbConvert Class

 

 


Send Comment