473,698 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Split select statement into two lines in c#

I have an extremely long and complex select statement as
shown below and I need to split it onto two lines but not
quite sure how to do it because I've never needed to
before. I need to split it onto two lines because I keep
getting this error :
Compiler limit exceeded: Line cannot exceed 2046 characters

Could someone please show me how this can be done.

("Select IPC.URN, SuspectName.Sur name,
SuspectName.For enames, SuspectName.Dat eOfBirthS75,
Suspect.Occupat ion, Ref_Gender.Desc ription,
SuspectAddress. Name, SuspectAddress. Townland,
SuspectAddress. Town, SuspectAddress. County,
SuspectAddress. Postcode, SuspectAddress. DCU,
Suspect.InCareF lag, Suspect.Solicit orFirmURN,
Suspect.PartyUR N, MilitaryPersonn el.ServiceUnit,
MilitaryPersonn el.MilitaryRank ,
MilitaryPersonn el.ServiceNumbe r,
MilitaryPersonn el.UnitAddress, Suspect.ChargeD ate,
Suspect.Interim Form1Flag,
Suspect.Interim ChargedSummonse dDate,
Suspect.Interim DateOfFirstCour t, Suspect.Interim Status,
Ref_InterimStat us.Description,
SuspectPrincipa lEvidence.Type,
SuspectPrincipa lEvidence.Other Description,
Ref_PrincipalEv idenceType.Desc ription,
SuspectMotivati on.Type, Ref_MotivationT ype.Description ,
Suspect.Evidenc eAssessment,Ref _SuspectAssessm entOfEvidence.
Description,
Suspect.Outstan dingEvidenceOnS ubmissionToPros ecutionFlag,
Suspect.OtherDe scription, Suspect.Driving NumberOfYears
FROM ((((Suspect left outer JOIN MilitaryPersonn el ON
Suspect.URN = MilitaryPersonn el.SuspectURN) left outer
JOIN SuspectAddress ON Suspect.URN =
SuspectAddress. SuspectURN) left outer JOIN
SuspectMotivati on ON Suspect.URN =
SuspectMotivati on.SuspectURN) left outer JOIN
SuspectPrincipa lEvidence ON Suspect.URN =
SuspectPrincipa lEvidence.Suspe ctURN)left outer JOIN
SuspectName ON Suspect.URN = SuspectName.Sus pectURN left
outer JOIN Party on Suspect.PartyUR N = Party.URN left
outer JOIN Individual on Party.URN = Individual.Part yURN
left outer JOIN IPC on Suspect.IPCURN = IPC.URN left outer
JOIN Ref_Gender on Individual.Gend er = Ref_Gender.code
left outer JOIN Ref_InterimStat us on Suspect.Interim Status
= Ref_InterimStat us.Description left outer JOIN
Ref_PrincipalEv idenceType on SuspectPrincipa lEvidence.Type
= Ref_PrincipalEv idenceType.Code left outer JOIN
Ref_MotivationT ype on SuspectMotivati on.Type =
Ref_MotivationT ype.Code left outer JOIN
Ref_SuspectAsse ssmentOfEvidenc e on
Suspect.Evidenc eAssessment =
Ref_SuspectAsse ssmentOfEvidenc e.Code where IPC.URN = 101
and Suspect.URN = 40", conSQL);
Nov 16 '05 #1
4 11261
Just break your string into multiple strings and concatenate, e.g.

string sqlQuery = "Select IPC.URN, SuspectName.Sur name, " +
"SuspectName.Fo renames, SuspectName.Dat eOfBirthS75, " +
...
"and Suspect.URN = 40";

Ken
"Anna Smith" <an*******@disc ussions.microso ft.com> wrote in message
news:0a******** *************** *****@phx.gbl.. .
I have an extremely long and complex select statement as
shown below and I need to split it onto two lines but not
quite sure how to do it because I've never needed to
before. I need to split it onto two lines because I keep
getting this error :
Compiler limit exceeded: Line cannot exceed 2046 characters

Could someone please show me how this can be done.

("Select IPC.URN, SuspectName.Sur name,
SuspectName.For enames, SuspectName.Dat eOfBirthS75,
Suspect.Occupat ion, Ref_Gender.Desc ription,
SuspectAddress. Name, SuspectAddress. Townland,
SuspectAddress. Town, SuspectAddress. County,
SuspectAddress. Postcode, SuspectAddress. DCU,
Suspect.InCareF lag, Suspect.Solicit orFirmURN,
Suspect.PartyUR N, MilitaryPersonn el.ServiceUnit,
MilitaryPersonn el.MilitaryRank ,
MilitaryPersonn el.ServiceNumbe r,
MilitaryPersonn el.UnitAddress, Suspect.ChargeD ate,
Suspect.Interim Form1Flag,
Suspect.Interim ChargedSummonse dDate,
Suspect.Interim DateOfFirstCour t, Suspect.Interim Status,
Ref_InterimStat us.Description,
SuspectPrincipa lEvidence.Type,
SuspectPrincipa lEvidence.Other Description,
Ref_PrincipalEv idenceType.Desc ription,
SuspectMotivati on.Type, Ref_MotivationT ype.Description ,
Suspect.Evidenc eAssessment,Ref _SuspectAssessm entOfEvidence.
Description,
Suspect.Outstan dingEvidenceOnS ubmissionToPros ecutionFlag,
Suspect.OtherDe scription, Suspect.Driving NumberOfYears
FROM ((((Suspect left outer JOIN MilitaryPersonn el ON
Suspect.URN = MilitaryPersonn el.SuspectURN) left outer
JOIN SuspectAddress ON Suspect.URN =
SuspectAddress. SuspectURN) left outer JOIN
SuspectMotivati on ON Suspect.URN =
SuspectMotivati on.SuspectURN) left outer JOIN
SuspectPrincipa lEvidence ON Suspect.URN =
SuspectPrincipa lEvidence.Suspe ctURN)left outer JOIN
SuspectName ON Suspect.URN = SuspectName.Sus pectURN left
outer JOIN Party on Suspect.PartyUR N = Party.URN left
outer JOIN Individual on Party.URN = Individual.Part yURN
left outer JOIN IPC on Suspect.IPCURN = IPC.URN left outer
JOIN Ref_Gender on Individual.Gend er = Ref_Gender.code
left outer JOIN Ref_InterimStat us on Suspect.Interim Status
= Ref_InterimStat us.Description left outer JOIN
Ref_PrincipalEv idenceType on SuspectPrincipa lEvidence.Type
= Ref_PrincipalEv idenceType.Code left outer JOIN
Ref_MotivationT ype on SuspectMotivati on.Type =
Ref_MotivationT ype.Code left outer JOIN
Ref_SuspectAsse ssmentOfEvidenc e on
Suspect.Evidenc eAssessment =
Ref_SuspectAsse ssmentOfEvidenc e.Code where IPC.URN = 101
and Suspect.URN = 40", conSQL);

Nov 16 '05 #2
Hi Anna,
string selectstring = "Select IPC.URN, SuspectName.Sur name, "
+ "SuspectName.Fo renames, SuspectName.Dat eOfBirthS75, "
+ " ... "
+ "and Suspect.URN = 40";

Just add + between each string and it will be added together as a single string.
You can also use StringBuilder which is much preferred if you concatenate lots of strings.

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
It should be pointed out that you should use string builder if you need
to create long strings that are dynamic in nature. If your strings are
constant, then using StringBuilder would actually work against you.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Morten Wennevik" <Mo************ @hotmail.com> wrote in message
news:opsdchyhqr klbvpo@stone...
Hi Anna,
string selectstring = "Select IPC.URN, SuspectName.Sur name, "
+ "SuspectName.Fo renames, SuspectName.Dat eOfBirthS75, "
+ " ... "
+ "and Suspect.URN = 40";

Just add + between each string and it will be added together as a single
string.
You can also use StringBuilder which is much preferred if you concatenate
lots of strings.

--
Happy coding!
Morten Wennevik [C# MVP]

Nov 16 '05 #4
Just split the string somewhere and concat it with a "+";

your string: string test = "verylongverylo ng";
to: string test = "verylong"+
"verylong";

Thats it...

What for an application is this? The select statement looks kind of interesting :D
Nov 16 '05 #5

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

Similar topics

0
2611
by: Marian Heddesheimer | last post by:
Hi, does anybody know a good pattern for PHP regular expression (like preg_match) to split an existing SQL statement into their parts? For example, if I have this: $sql = "select field1, field2 from tab1, tab2 where tab1.id = tab2.id order by tab2.title, tab1.id";
14
2139
by: Luka Milkovic | last post by:
Hello, I have a little problem and although it's little it's extremely difficult for me to describe it, but I'll try. I have written a program which extracts certain portions of my received e-mail. The content of the e-mail is actually predictable, it has one very long list of numbers, something looking like this:
3
4420
by: rxl124 | last post by:
Hi, room Beginner of learning perl here!! I have question to all, I have below file name datebook.master which contains only 2 lines Mike wolf:12/3/44:144 park ave, paramus: 44000 Sarah kim: 3/2/67:255 lomel ave, fort lee: 33000 Now, I am testing out below scripts and working fine.
0
10203
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the database table, using dynamic sql. Executing 'EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;' the error code -2149 is returned That means "Specified partition does not exist". Does anybody know if it is a database problem or a problem of
3
6462
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too long, as there's a limit to the length of the SQL statement(s). But this works when I don't try to...
7
9331
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
3
9665
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3... field1...field2...field3...
3
1758
by: ImOk | last post by:
I have this PHP statement which works fine and breaks down a string of lines delimited with a \r into an array. $arrList=split("\r", $strList); But what I really want is to be able to tell it to split out only the strings that start with the letter "b". E.g. I thought this would work "b\W\r"
9
2194
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but that has problems. FullName=Request.Form("Name") Email=Request.Form("Email") GivenName=Request.Form("GivenName")
0
8672
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
8600
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
9155
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9018
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
8890
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
8858
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5859
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();...
2
2322
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.