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:
00855080
Views:
16
>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.
>

Well, there are two ways. You could use a typed ADO.NET dataset, so when you get that column from your DataRow you would not get an object but a decimal.
CustomDataSet ds = new CustomDataSet();
int RowNumber = 0;
if(ds.MyTable[RowNumber].SalesMin > 0) {
etc..
The other way is to cast the object to an int
(int)dsQuery["SalesMin"] > 0
You will run into problems if you are trying to cast a null object though.

Morgan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform