469,954 Members | 1,746 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

C# breaking up long lines of code

123 100+
I've searched a few websites and none of them meantion how to break up really long lines of code like a sql query.

The sql statement looks like this (I've broked it down so it can fit in the post):
String sSQL = "SELECT dbo.Issues.CreatedDate as Created, dbo.Issues.ModifiedDate as Modified, dbo.Issues.Field1 AS Repro, dbo.Issues.Field3 AS Notes dbo.Issues.Field2 as Priority, dbo.Issues.Field11 AS Build, dbo.Issues.Field12 as Description, dbo.Issues.Field25 AS VersionIn, dbo.Issues.Field26 As VersionFixed dbo.Issues.ID,dbo.Types.Name AS Type, dbo.Issues.Synopsis dbo.States.Name AS State, dbo.States.ID AS StatesID, dbo.Users.Name AS [User], dbo.Projects.Name AS Projects FROM dbo.Issues INNER JOIN dbo.Projects ON dbo.Issues.ProjectID = dbo.Projects.ID INNER JOIN dbo.States ON dbo.Issues.StateID = dbo.States.ID INNER JOIN dbo.Types ON dbo.Issues.TypeID = dbo.Types.ID INNER JOIN dbo.Users ON dbo.Issues.AssignedUserID = dbo.Users.ID WHERE ( dbo.Projects.ID = 66)";

I'm not sure if this post should be here, but I figured it is worth a shot. Thanks for any advice.
Newbie19
Jan 3 '08 #1
4 1860
weaknessforcats
9,208 Expert Mod 8TB
You shouold be able to:
Expand|Select|Wrap|Line Numbers
  1. String sSQL = "SELECT dbo.Issues.CreatedDate as Created,"
  2.                      + " dbo.Issues.ModifiedDate as Modified,"
  3.                      + " dbo.Issues.Field1 AS Repro,"
  4.                      + " dbo.Issues.Field3 AS Notes dbo.Issues.Field2 as Priority,"
  5.                      +etc....
  6.  
Jan 3 '08 #2
Newbie19
123 100+
You shouold be able to:
Expand|Select|Wrap|Line Numbers
  1. String sSQL = "SELECT dbo.Issues.CreatedDate as Created,"
  2.                      + " dbo.Issues.ModifiedDate as Modified,"
  3.                      + " dbo.Issues.Field1 AS Repro,"
  4.                      + " dbo.Issues.Field3 AS Notes dbo.Issues.Field2 as Priority,"
  5.                      +etc....
  6.  
Thank you very much, C# is more like Java then I realized.

Thanks again,

Newbie19
Jan 3 '08 #3
Plater
7,872 Expert 4TB
Thank you very much, C# is more like Java then I realized.

Thanks again,

Newbie19
You can also do:
Expand|Select|Wrap|Line Numbers
  1. String sSQL = "";
  2. sSQL += "SELECT dbo.Issues.CreatedDate as Created,";
  3. sSQL += " dbo.Issues.ModifiedDate as Modified,"
  4. sSQL += " dbo.Issues.Field1 AS Repro,"
  5. sSQL += " dbo.Issues.Field3 AS Notes dbo.Issues.Field2 as Priority,"
  6. //sSQL += etc....
  7.  
(There is a "cost" with this as it re-creates the string everytime.)
Jan 3 '08 #4
camel
55
If you are going to need a lot of concatenations best option is likely the System.Text.StringBuilder which overcomes the performance issues of +=
Jan 3 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Michael Satterwhite | last post: by
87 posts views Thread by Frances Del Rio | last post: by
27 posts views Thread by The Bicycling Guitarist | last post: by
22 posts views Thread by stevenkobes | last post: by
1 post views Thread by BerkshireGuy | last post: by
49 posts views Thread by elmar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.