Re: DataColumn.Expression error handling
From: pali (pali_at_discussions.microsoft.com)
Date: 07/01/04
- Next message: sean: "Re: help with SQL queries"
- Previous message: sean: "SO WHY BOTHER?"
- In reply to: Miha Markic [MVP C#]: "Re: DataColumn.Expression error handling"
- Next in thread: Miha Markic [MVP C#]: "Re: DataColumn.Expression error handling"
- Reply: Miha Markic [MVP C#]: "Re: DataColumn.Expression error handling"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 1 Jul 2004 05:35:01 -0700
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... 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: sean: "Re: help with SQL queries"
- Previous message: sean: "SO WHY BOTHER?"
- In reply to: Miha Markic [MVP C#]: "Re: DataColumn.Expression error handling"
- Next in thread: Miha Markic [MVP C#]: "Re: DataColumn.Expression error handling"
- Reply: Miha Markic [MVP C#]: "Re: DataColumn.Expression error handling"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|