Solved

get values through embedded sql command (string builder)

Posted on 2008-10-28
2
679 Views
Last Modified: 2012-05-05
I am trying to get values using embeded SQL.

I have written something like the following:
strQueryText.AppendLine("RuleNumber = RuleNumberBlackJack + RuleNumberPoker,")
..
..
Some Calculations
..
..
strQueryText.AppendLine("ORDER BY RuleNumber")

This works fine and it should :). But the issue is: i want to ORDER BY RuleNumberPoker which is
 
strQueryText.AppendLine("ORDER BY")
strQueryText.AppendLine("CASE WHEN RuleNumberPoker LIKE '%^[0-9.]%' then RuleNumberPoker ELSE NULL END,")
strQueryText.AppendLine("CASE WHEN RuleNumberPoker LIKE '%[0-9.]%' then CONVERT(float, RuleNumberPoker) ELSE NULL END, RuleNumberPoker")

then concatanate both the rules. How do i do achieve this, please help
0
Comment
Question by:Kerau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
CtrlAltDl earned 500 total points
ID: 22826477
I'm not clear on what you are asking, but I'm going to take a guess that you are trying to concatenate a SQL string together.

Make sure there is a space between (before or after) each append.
strQueryText.AppendLine(" ORDER BY")
strQueryText.AppendLine(" CASE WHEN RuleNumberPoker LIKE '%^[0-9.]%' then RuleNumberPoker ELSE NULL END,")
strQueryText.AppendLine(" CASE WHEN RuleNumberPoker LIKE '%[0-9.]%' then CONVERT(float, RuleNumberPoker) ELSE NULL END, RuleNumberPoker")

Are you having troubles using the CASE statement within the ORDER BY clause?  If so there is an example 3/4 of the way down the page here:
http://www.4guysfromrolla.com/webtech/102704-1.shtml
0
 

Author Closing Comment

by:Kerau
ID: 31510723
sorry for the delayed post as i was out of town!! Thanks for your time, it was a useful information to me....Since nobody else bothered to post anything, guess what you get all the points...:)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question