Solved

get values through embedded sql command (string builder)

Posted on 2008-10-28
2
668 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
2 Comments
 
LVL 14

Accepted Solution

by:
CtrlAltDl earned 500 total points
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now