Split select statement into two lines in c#

  • Thread starter Thread starter Anna Smith
  • Start date Start date
A

Anna Smith

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.Surname,
SuspectName.Forenames, SuspectName.DateOfBirthS75,
Suspect.Occupation, Ref_Gender.Description,
SuspectAddress.Name, SuspectAddress.Townland,
SuspectAddress.Town, SuspectAddress.County,
SuspectAddress.Postcode, SuspectAddress.DCU,
Suspect.InCareFlag, Suspect.SolicitorFirmURN,
Suspect.PartyURN, MilitaryPersonnel.ServiceUnit,
MilitaryPersonnel.MilitaryRank,
MilitaryPersonnel.ServiceNumber,
MilitaryPersonnel.UnitAddress, Suspect.ChargeDate,
Suspect.InterimForm1Flag,
Suspect.InterimChargedSummonsedDate,
Suspect.InterimDateOfFirstCourt, Suspect.InterimStatus,
Ref_InterimStatus.Description,
SuspectPrincipalEvidence.Type,
SuspectPrincipalEvidence.OtherDescription,
Ref_PrincipalEvidenceType.Description,
SuspectMotivation.Type, Ref_MotivationType.Description,
Suspect.EvidenceAssessment,Ref_SuspectAssessmentOfEvidence.
Description,
Suspect.OutstandingEvidenceOnSubmissionToProsecutionFlag,
Suspect.OtherDescription, Suspect.DrivingNumberOfYears
FROM ((((Suspect left outer JOIN MilitaryPersonnel ON
Suspect.URN = MilitaryPersonnel.SuspectURN) left outer
JOIN SuspectAddress ON Suspect.URN =
SuspectAddress.SuspectURN) left outer JOIN
SuspectMotivation ON Suspect.URN =
SuspectMotivation.SuspectURN) left outer JOIN
SuspectPrincipalEvidence ON Suspect.URN =
SuspectPrincipalEvidence.SuspectURN)left outer JOIN
SuspectName ON Suspect.URN = SuspectName.SuspectURN left
outer JOIN Party on Suspect.PartyURN = Party.URN left
outer JOIN Individual on Party.URN = Individual.PartyURN
left outer JOIN IPC on Suspect.IPCURN = IPC.URN left outer
JOIN Ref_Gender on Individual.Gender = Ref_Gender.code
left outer JOIN Ref_InterimStatus on Suspect.InterimStatus
= Ref_InterimStatus.Description left outer JOIN
Ref_PrincipalEvidenceType on SuspectPrincipalEvidence.Type
= Ref_PrincipalEvidenceType.Code left outer JOIN
Ref_MotivationType on SuspectMotivation.Type =
Ref_MotivationType.Code left outer JOIN
Ref_SuspectAssessmentOfEvidence on
Suspect.EvidenceAssessment =
Ref_SuspectAssessmentOfEvidence.Code where IPC.URN = 101
and Suspect.URN = 40", conSQL);
 
Just break your string into multiple strings and concatenate, e.g.

string sqlQuery = "Select IPC.URN, SuspectName.Surname, " +
"SuspectName.Forenames, SuspectName.DateOfBirthS75, " +
...
"and Suspect.URN = 40";

Ken
 
Hi Anna,


string selectstring = "Select IPC.URN, SuspectName.Surname, "
+ "SuspectName.Forenames, SuspectName.DateOfBirthS75, "
+ " ... "
+ "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.
 
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.
 
Just split the string somewhere and concat it with a "+";

your string: string test = "verylongverylong";
to: string test = "verylong"+
"verylong";

Thats it...

What for an application is this? The select statement looks kind of interesting :D
 
Back
Top