Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
> operator vs. datarow column of System.Decimal type?
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00855035
Message ID:
00855163
Views:
13
Can you assign the value to a variable of type decimal, and then compare the variable with the ">" ? Ugly, but might work since .NET will do some of the casting for you.


>Newbie ADO.NET / C# question here. I have a datarow with a column of System.Decimal (Number(0) in Oracle) type and I want to find out whether that column's value is > 0.
>
>When I try the code below, I'm told "Operator '>' cannot be applied to operands of type 'object' and 'int'." I see in the .NET help that the System.Decimal type has a GreaterThan method. That should work fine for me, but Intellisense is not popping that up as a choice for the column. I know that it is a System.Decimal datatype though because I wrote the result of calling GetType() out to the web page I'm working on.
>
>Here's the method I'm working on and the error occurs on the "if" statement line.
>
>
>public string GetQueryDescription( DataRow drQuery )
>{
>  StringBuilder QueryDesc = new StringBuilder();
>
>  QueryDesc.Append( drQuery["QueryName"] + " - " );
>
>  if (drQuery["SalesMin"] > 0 )
>     QueryDesc.Append( "Sales " + drQuery["SalesMin"].ToString() + "MM+" );
>			
>  //TODO: String together other meaningful items for the description here...
>	
>  return QueryDesc.ToString();
>}
>
>
>I even tried casting my column to (System.Decimal) just in case and am then told that "'object' does not contain a definition for 'GreaterThan'."
>
>Based on those 2 different error messages, it would appear that drQuery["SalesMin"] is being seen as "just" an Object vs. a System.Decimal, even though .GetType does return System.Decimal.
>
>Any ideas? Thanks.
>
>Kelly
Hector Correa
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform