473,803 Members | 4,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String Declaration

I have an SQL statement which is quite long. I want to declare a string
variable with this SQL statement and I want to have span multiple lines. I
could scrunch it all up and place it on a single line, but then the SQL
statement would be unreadable. There was a way to do this in VB, but how do
you do this is C#?

I want it to look something like this in the code.

string mySQL = "select 'Anchor' as Anchor_NonAncho r, combo.PROCESS_G ROUP,
combo.COMBINATI ON, cf.CHARTFIELD,
grp.COMBO_DEFN_ NAME, ' ' as Tree_Name, ' ' as
Node_Name,
cf.SEQUENCE_NBR _6, cval.SELECT_VAL UE as Range_From,
' ' as
Range_To
from gapsc.ps_combo_ grrul_tbl combo,
gapsc.ps_combo_ rule_tbl Rul,
gapsc.ps_combo_ group_tbl grp,
gapsc.ps_combo_ cf_tbl cf,
gapsc.ps_combo_ val_tbl cval
where Rul.EFFDT_TO = '2099-01-01'
and rul.combination = combo.combinati on
and grp.setid = rul.setid
and combo.setid = cf.setid
and rul.combination = cf.combination
and rul.combination = cval.combinatio n
and grp.Process_Gro up = combo.Process_G roup
and grp.combo_defn_ name = rul.combo_Defn_ Name
and cf.SETID = cval.SETID
and cf.COMBINATION = cval.COMBINATIO N
and cf.SEQUENCE_NBR _6 = cval.SEQUENCE_N BR_6
and cf.TREE_NAME = ' ' ";

Thanks in advance!!
Oct 27 '06 #1
2 2041
string mySQL = @"Some long
text with "" double quote escapting of single quotes
that goes on and on and on";

Or use an sp (or the equivalent name for your database) ;-p

(oh don't look at me like that... someone was bound to say it!)

Marc
Oct 27 '06 #2
Marc Gravell wrote:
string mySQL = @"Some long
text with "" double quote escapting of single quotes
that goes on and on and on";

Or use an sp (or the equivalent name for your database) ;-p

(oh don't look at me like that... someone was bound to say it!)

Marc
Just for completeness, you can also continue your string onto the next
line:

string mySQL = "SELECT field1, field2 " +
" FROM table " +
"WHERE Id = @Id";

Oct 27 '06 #3

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

Similar topics

4
19904
by: Jeff Williams | last post by:
This doesn't compile: const char** ids = { "aaa", "bbb", "ccc" }; I hope the above illustrates what I am trying to do, if it is possible, what
12
16231
by: Riley DeWiley | last post by:
I am looking for a graceful way to declare a string const that is to be visible across many files. If I do this: //----hdr.h const char * sFoo = "foo"; //file.cpp
5
11742
by: MLH | last post by:
I'm working with lots of long strings now, it seems. I have to import them & parse them constantly. The A97 memo field type supports only 32768 chars. What happens when this is processed... Dim MyString As String Am I getting VLS declaration or a FLS declaration? Can I control which I get somehow? I have done some homework, but I don't understand
7
4368
by: al | last post by:
char s = "This string literal"; or char *s= "This string literal"; Both define a string literal. Both suppose to be read-only and not to be modified according to Standard. And both have type of "const char *". Right? But why does the compiler I am using allow s to be modified, instead of generating compile error?
4
5401
by: songkv | last post by:
Hi, I am trying to reassign an array of char to a string literal by calling a function. In the function I use pointer-to-pointer since I want to reassign the "string array pointer" to the string literal. But the second printf seems to give me garbage. Any advise on what I am doing wrong? Thanx
12
919
by: Terry | last post by:
If the string object contain like below: string Mystring = " "; What function should be used for checking the "Mystring" is no char inside? Thanks Terry
24
2713
by: v4vijayakumar | last post by:
why the following string, 'str' is read-only? char *str = "test string"; anyhow 'str' needs to be in memory. do you think, making 'str' red-only would gain performance? or, it is right?
31
3142
by: Peter Michaux | last post by:
Hi, I want to know the name of an object's constructor function as a string. Something like this <script type="text/javascript"> function Foo(){}; var a = new Foo(); alert('"' + a.constructor.toString().match(/function\s*(+)/)
5
2900
by: polas | last post by:
Good morning, I have a quick question to clear up some confusion in my mind. I understand that using a string literal in a declaration such as char *p = "string literal" declares a pointer to memory holding the string and the string might very well be held in read only memory. However, I am sure that I read somewhere that the declaration char a = "string literal", even though a is an array (and I understand the differences between...
4
3830
by: Chris Forone | last post by:
hello group, why have i to bracket the second ctor param in the following example? thx & hand, chris #include <fstream> #include <iterator> int main()
0
9700
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
9564
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10310
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
10292
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
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6841
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
5498
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...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
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

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.