Solved

get values through embedded sql command (string builder)

Posted on 2008-10-28
2
676 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
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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