Re: DataColumn.Expression error handling
From: Miha Markic [MVP C#] (miha)
Date: 07/01/04
- Next message: Piotr: "Re: Typed DataSets and Relations"
- Previous message: John: "Using dataadapter"
- In reply to: pali: "Re: DataColumn.Expression error handling"
- Next in thread: Marina: "Re: DataColumn.Expression error handling"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 1 Jul 2004 15:13:02 +0200
"pali" <pali@discussions.microsoft.com> wrote in message
news:A62B693C-F808-4287-8E00-3E4DCFAFC124@microsoft.com...
> Hi, thanx for the reply, this doesn't solve my problem though.
> In your example, I would never get the NaN message, since budget_ext_price
would never be 0 but 1 instead, and I would really like to display the NaN
message...
Why not? I changed only the result which you never actually get...
-- Miha Markic [MVP C#] - RightHand .NET consulting & development miha at rthand com www.rthand.com I solved it on the database side in the mean time (because of the tight schedule), but I was wondering, is there ANY way to get the behavior I want from the Expression (i. e. in case of DIV/0 display message, otherwise the result) > > "Miha Markic [MVP C#]" wrote: > > > Hi pali, > > > > This is vb behaviour where IIF is a procedure that you pass parameters to. > > It is not the same as ?: operator in C# I believe. > > Thus you might modify it a bit just to avoid an exception: > > IIF(budget_ext_price = 0, 'NaN', material_margin / iif(budget_ext_price=0, > > 1, budget_ext_price))" > > > > Didn't test it but it might work :-) > > > > -- > > Miha Markic [MVP C#] - RightHand .NET consulting & development > > miha at rthand com > > www.rthand.com > > > > "pali" <pali@discussions.microsoft.com> wrote in message > > news:607B25D3-2DC9-42F5-AF61-C3AA54EED884@microsoft.com... > > > Hi, > > > I need to compute a percentage in a DataTable, so i'm trying to use the > > Expression property provided by the DataColumn object. My problem is the > > classic division by zero error. > > > This is my expression: > > > "IIF(budget_ext_price = 0, 'NaN', material_margin / budget_ext_price)" > > > Now, it seems that the material_margin / budget_ext_price expression is > > being evaluated regardless of the condition. If i replace the '/' with '-', > > I get correctly NaN in one row, though with '/' I get division by zero > > exception. Is the false part really being evaluated, even in the case the > > condition is true? > > > > > >
- Next message: Piotr: "Re: Typed DataSets and Relations"
- Previous message: John: "Using dataadapter"
- In reply to: pali: "Re: DataColumn.Expression error handling"
- Next in thread: Marina: "Re: DataColumn.Expression error handling"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|