473,698 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CASE or IF statement in Datacolumn.Expr ession

Hi,

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

Here's what I've tried:

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

But I keep getting errors like this:

Syntax error: Missing operand after 'StandardsBodyI D' 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 7974
On Sun, 28 Oct 2007 00:54:07 -0000, jelling <jo*******@yaho o.com>
wrote:
>Hi,

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

Here's what I've tried:

'standardCodeCo lumn.Expression = "CASE StandardsBodyID
WHEN 1 THEN 'JCAHO' ELSE 'Non-JCAHO' END"
'standardCodeCo lumn.Expression = "CASE WHEN
StandardsBodyI D = 1 THEN 'JCAHO' ELSE 'Non-JCAHO' END"

But I keep getting errors like this:

Syntax error: Missing operand after 'StandardsBodyI D' 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.dat acolumn.express ion.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
4696
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 <iomanip> #include <iostream> using namespace std;
3
18715
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 with only 2 decimals (#,##0.00)? In the sample below, amount and taxrate are existing DataColumn's. DataColumn colTax = new DataColumn(); colTax.DataType = System.Type.GetType("System.String"); colTax.ColumnName = "tax";...
1
1712
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 just keys a company to a specific industry. This table can have multiple rows for a single company, since some companies can be involved in multiple industries. Now when I display Companies in a DataGrid, I want a column that prints out all the...
1
2868
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 dataset in VB.NET I figured this was the next logical place to ask my question. I'm using the DataColumn.Expression property, and when I call the function with a '\' I get a crash.
1
21678
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 "01" : dWarrExpDateMonth="Jan" : dRetailDateMonth="Jan" case "02" : dWarrExpDateMonth="Feb" : dRetailDateMonth="Feb" End Select
11
21897
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 another datetime column in the table. See sample below. How do I do this? Any help would be greatly appreciated. Thanks Private Sub CreateDataTable() dt = New DataTable
0
2279
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 = "my_custom(Child.Test)"; Anyone done this before? Any suggestions on where to start? thanks
0
4557
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 columns to make a derived column. When I run my code, I get this error: ------------
56
6728
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 6.4.2(2) : case constant-expression : I propose that the case expression of the switch statement be changed from "integral constant-expression" to "integral expression".
0
8680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.