473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CASE or IF statement in Datacolumn.Expression

Hi,

Is it possible to use a CASE or IF ELSE statement in a datacolumn
expression?

Here's what I've tried:

'standardCodeColumn.Expression = "CASE StandardsBodyID
WHEN 1 THEN 'JCAHO' ELSE 'Non-JCAHO' END"
'standardCodeColumn.Expression = "CASE WHEN
StandardsBodyID = 1 THEN 'JCAHO' ELSE 'Non-JCAHO' END"

But I keep getting errors like this:

Syntax error: Missing operand after 'StandardsBodyID' operator

Please help if you can. I know we can do this at the SQL View level
but its a requirement in this case to move that logic to the BLL/DAL
layer.

Thank you,

..jelling

Oct 28 '07 #1
1 7926
On Sun, 28 Oct 2007 00:54:07 -0000, jelling <jo*******@yahoo.com>
wrote:
>Hi,

Is it possible to use a CASE or IF ELSE statement in a datacolumn
expression?

Here's what I've tried:

'standardCodeColumn.Expression = "CASE StandardsBodyID
WHEN 1 THEN 'JCAHO' ELSE 'Non-JCAHO' END"
'standardCodeColumn.Expression = "CASE WHEN
StandardsBodyID = 1 THEN 'JCAHO' ELSE 'Non-JCAHO' END"

But I keep getting errors like this:

Syntax error: Missing operand after 'StandardsBodyID' operator

Please help if you can. I know we can do this at the SQL View level
but its a requirement in this case to move that logic to the BLL/DAL
layer.
The Help for Expression pretty clearly explains what is legal:

<http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx>

It looks like IIF() will do what you want.
Oct 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: deanfamily11 | last post by:
I've set up a case statement to have my program determine where on the Cartesian plane a point the user enters is located. I keep getting the C2051 error when I compile. Any help? #include...
3
by: J | last post by:
Is there anyway to format a calculated datacolumn? I would like the following column to display as money (formatted as $#,##0.00). Or how about simply displaying the column formatted as a number...
1
by: MrNobody | last post by:
Say I have a table of companies, and a table of industries (like automobiles, steel, computers, etc..) A company may be involved in industries, so there's a third table- a mapping table- which...
1
by: Jason | last post by:
First off, I tried to find an ADO.NET forum, or even just a .NET framework forum but couldn't seem to locate one and I apologize in advance if I've posted in the wrong place. Because I'm using a...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
11
by: Matt F | last post by:
I'm trying to do something that seems like it should be pretty simple, but haven't found a solution. I am trying to add a datacolumn to a datatable that adds or subtracts a number of days based on...
0
by: whiteboy | last post by:
I want to create my own Aggregate function to be used in the DataColumn.Expression property. So for example, DataColumn col = new DataColumn("foo", typeof(String)); col.Expression =...
0
by: SMH | last post by:
Hi All, I am currently learning .Net 2, studying for 70-528. I've hit a bit of a brick wall with DataColumn.Expression. As I understand it, this can be used to (For example) concatenate two...
56
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.