473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How To: Do multi-line string vars?

I'm running into a situation where I want to take a multi-line SQL
statement and include it as a string in my code. I know that I can do
something like

strSQL = "SELECT * "
strSQL &= "FROM tbl.dbo.MyTable, "
strSQL &= " tbl.dbo.MyTable2 "
strSQL &= "WHERE MyTable.ID = MyTable2.ID "
strSQL &= "ORDER BY Date DESC"

but is there a way to do something like

strSQL = ::BOF::
SELECT *
FROM tbl.dbo.MyTable,
tbl.dbo.MyTable2
WHERE MyTable.ID = MyTable2.ID
ORDER BY Date DESC
::EOF::

?

I know it sounds like a petty issue, but some of these SQL statements
are scores of lines long, and are subject to overhaul from time to
time... if there was a way to do what I'm looking for, I could save some
5-10 minutes of formatting headaches. I'm afraid I know the answer
already (as "No") but I figured it wouldn't hurt to ask.

Thanks,
Scott
Jul 21 '05 #1
2 2424
Ho Scott

I may not have the exact answer you are looking for, but a possible
alternative

Use the StringBuilder class ,
This will give you 2 great abilities
1. You can change the lines fairly quickly and easy
2. Formatting, very handy feature

Exp.
StringBuilder sbSql = new StringBuilder() ;
sbSql.Append("SELECT * ") ;
sbSql.AppendFormat("FROM {0}, ","tbl.dbo.MyTable") ; //just to illustrate
sbSql.Append(" WHERE MyTable.ID = MyTable2.ID ")

This may help in inserting, altering strings as well as passing dynamic
related information
Henk
"Scott McNair" <sc**********@sfmco.takethispartout.com> wrote in message
news:Xn*******************@207.46.248.16...
I'm running into a situation where I want to take a multi-line SQL
statement and include it as a string in my code. I know that I can do
something like

strSQL = "SELECT * "
strSQL &= "FROM tbl.dbo.MyTable, "
strSQL &= " tbl.dbo.MyTable2 "
strSQL &= "WHERE MyTable.ID = MyTable2.ID "
strSQL &= "ORDER BY Date DESC"

but is there a way to do something like

strSQL = ::BOF::
SELECT *
FROM tbl.dbo.MyTable,
tbl.dbo.MyTable2
WHERE MyTable.ID = MyTable2.ID
ORDER BY Date DESC
::EOF::

?

I know it sounds like a petty issue, but some of these SQL statements
are scores of lines long, and are subject to overhaul from time to
time... if there was a way to do what I'm looking for, I could save some
5-10 minutes of formatting headaches. I'm afraid I know the answer
already (as "No") but I figured it wouldn't hurt to ask.

Thanks,
Scott

Jul 21 '05 #2
2 suggestions:

1) write the SQL-String in an external file and read it in at runtime
2) use stored procedures in the DB ;-)

Jon

"Scott McNair" <sc**********@sfmco.takethispartout.com> schrieb im
Newsbeitrag news:Xn*******************@207.46.248.16...
I'm running into a situation where I want to take a multi-line SQL
statement and include it as a string in my code. I know that I can do
something like

strSQL = "SELECT * "
strSQL &= "FROM tbl.dbo.MyTable, "
strSQL &= " tbl.dbo.MyTable2 "
strSQL &= "WHERE MyTable.ID = MyTable2.ID "
strSQL &= "ORDER BY Date DESC"

but is there a way to do something like

strSQL = ::BOF::
SELECT *
FROM tbl.dbo.MyTable,
tbl.dbo.MyTable2
WHERE MyTable.ID = MyTable2.ID
ORDER BY Date DESC
::EOF::

?

I know it sounds like a petty issue, but some of these SQL statements
are scores of lines long, and are subject to overhaul from time to
time... if there was a way to do what I'm looking for, I could save some
5-10 minutes of formatting headaches. I'm afraid I know the answer
already (as "No") but I figured it wouldn't hurt to ask.

Thanks,
Scott

Jul 21 '05 #3

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

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
2
by: Aussie Rules | last post by:
Hi, I have a site that Iwant to either display my text in english or french, based on the users prefernces ? I am new to webforms, but I know in winforms, this is pretty easy with a resource...
14
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
As far as I know, the C Standard has no mention of multi-threaded programming; it has no mention of how to achieve multi-threaded programming, nor does it mention whether the language or its...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.