dcsimg
Results 1 to 19 of 19

Thread: [RESOLVED] Too many line continuations

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    Resolved [RESOLVED] Too many line continuations

    While Creating string for SQL query i am getting error message from vb6 that "Too many line continuations"

    strSql = "CREATE TABLE " & Tabledd & _
    "(CNum int IDENTITY(1,1) PRIMARY KEY ," & _
    "CC char (4)," & _
    "PartnerId nvarchar (12)," & _
    "CC2 nvarchar (20)," & _
    "CC3 nvarchar (20)," & _
    "CC4 nvarchar (50)," & _
    "CC5 nvarchar (50)," & _
    "CC6 nvarchar(50)," & _
    "CC7 nvarchar (80)," & _
    "CC8 nvarchar(80)," & _
    "CC9 nvarchar (50)," & _
    "CC11 nvarchar (50)," & _
    "FF nvarchar (50)," & _
    "Password nvarchar(50)," & _
    "URL nvarchar(150)," & _
    "VV numeric (9)," & _
    " ProxyAddress nvarchar(100)," & _
    "VV varchar(50)," & _
    "EE varchar(50)," & _
    "QQ varchar(50)," & _
    "BB int ," & _
    "QQ varchar(10)," & _
    "NN numeric(9)," & _
    "MM varchar(20)) "

    if i try to add one more line it will give me error message. how can i avoid that error?

  2. #2

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    Re: Too many line continuations

    so what i have to do now?

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,028

    Re: Too many line continuations

    Code:
    strSql = "CREATE TABLE " & Tabledd & "(CNum int IDENTITY(1,1) PRIMARY KEY ," & "CC char (4)," & "PartnerId nvarchar (12)," & "CC2 nvarchar (20)," & _
    "CC3 nvarchar (20)," & _
    "CC4 nvarchar (50)," & _
    "CC5 nvarchar (50)," & _
    "CC6 nvarchar(50)," & _
    "CC7 nvarchar (80)," & _
    "CC8 nvarchar(80)," & _
    "CC9 nvarchar (50)," & _
    "CC11 nvarchar (50)," & _
    "FF nvarchar (50)," & _
    "Password nvarchar(50)," & _
    "URL nvarchar(150)," & _
    "VV numeric (9)," & _
    " ProxyAddress nvarchar(100)," & _
    "VV varchar(50)," & _
    "EE varchar(50)," & _
    "QQ varchar(50)," & _
    "BB int ," & _
    "QQ varchar(10)," & _
    "NN numeric(9)," & _
    "MM varchar(20)) "
    etc.

  5. #5
    #28 for the Yanks coming GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,268

    Re: Too many line continuations

    Now you start again:

    Code:
    strSql = "CREATE TABLE " & Tabledd & _
    "(CNum int IDENTITY(1,1) PRIMARY KEY ," & _
    "CC char (4)," & _
    "PartnerId nvarchar (12)," & _
    "CC2 nvarchar (20)," & _
    "CC3 nvarchar (20)," & _
    "CC4 nvarchar (50)," & _
    "CC5 nvarchar (50)," & _
    "CC6 nvarchar(50)," & _
    "CC7 nvarchar (80)," & _
    "CC8 nvarchar(80)," & _
    "CC9 nvarchar (50)," & _
    "CC11 nvarchar (50)," & _
    "FF nvarchar (50)," & _
    "Password nvarchar(50)," & _
    "URL nvarchar(150)," & _
    "VV numeric (9)," & _
    " ProxyAddress nvarchar(100)," & _
    "VV varchar(50)," & _
    "EE varchar(50)," & _
    "QQ varchar(50)," & _
    "BB int ," & _
    "QQ varchar(10)," & _
    "NN numeric(9)," 
    strsql = strsql & "MM varchar(20)," & _ 
    "Keep going".......
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  6. #6
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Too many line continuations

    Maybe he doesn't understand what a line continuation is. (No offence ofcourse! But it could be?)

    The _ character you use is used to split a single line into multiple lines.
    This is often used to make a long line of code more readable.

    These 2 are exactly the same:
    Code:
    This line in VB is one long line
    Code:
    This line _
    in VB is _
    one long line
    So in other words, if you don't want to reach this limit, simply use less line continuations.

    For example:
    Code:
    strSql = "CREATE TABLE " & Tabledd & "(CNum int IDENTITY(1,1) PRIMARY KEY ," & "CC char (4)," & _
    "PartnerId nvarchar (12)," & "CC2 nvarchar (20)," & "CC3 nvarchar (20)," & _
    etc...
    As you can see I simply deleted the _ and linebreaks between a few parts of the line.

  7. #7
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Too many line continuations

    I never use line continuations for SQL. Try this
    Code:
    strSql = "CREATE TABLE " & Tabledd 
    strSql = strSql & " (CNum int IDENTITY(1,1) PRIMARY KEY ," 
    strSql = strSql & " CC char (4)," 
    strSql = strSql & " PartnerId nvarchar (12)," 
    strSql = strSql & " CC2 nvarchar (20)," 
    strSql = strSql & " CC3 nvarchar (20)," 
    strSql = strSql & " CC4 nvarchar (50)," 
    strSql = strSql & " CC5 nvarchar (50)," 
    strSql = strSql & " CC6 nvarchar(50)," 
    strSql = strSql & " CC7 nvarchar (80)," 
    strSql = strSql & " CC8 nvarchar(80)," 
    strSql = strSql & " CC9 nvarchar (50)," 
    strSql = strSql & " CC11 nvarchar (50)," 
    strSql = strSql & " FF nvarchar (50)," 
    strSql = strSql & " Password nvarchar(50)," 
    strSql = strSql & " URL nvarchar(150)," 
    strSql = strSql & " VV numeric (9)," 
    strSql = strSql & "  ProxyAddress nvarchar(100)," 
    strSql = strSql & " VV varchar(50)," 
    strSql = strSql & " EE varchar(50)," 
    strSql = strSql & " QQ varchar(50)," 
    strSql = strSql & " BB int ,"
    strSql = strSql & " QQ varchar(10),"
    strSql = strSql & " NN numeric(9)," 
    strSql = strSql & " MM varchar(20)) "
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  8. #8
    Lurker
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Too many line continuations

    Hack, that's really inefficient. Every time you append data to a string, a new string has to be created, and the old data copied into it.
    You should at least work out the length of the query first, and then make the string long enough to hold all of it.
    Either that, or store the queries in a resource file—that way you wouldn't have to worry about any of this; plus, they are more readable and all collected in one place for ease of maintenance.

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Too many line continuations

    Quote Originally Posted by penagate
    Hack, that's really inefficient...
    So what pen? You build your string, use it and destroy it. What's the big deal?
    I don't see any problem with that. Never had any performance issues what so ever and believe me quite often dynamic sql could be huge.

  10. #10
    Lurker
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Too many line continuations

    I didn't say it was a big deal, did I?

  11. #11
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Too many line continuations

    But I wasn't sarcastic though... It's just an expression that people often use where I am.

    But seriously, I often hear about the string concatenation inefficiency.
    Theoretically it's true (and it's easy enough to prove it) but practically I am yet to encounter any issues.

  12. #12
    Lurker
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Too many line continuations

    OK. Sorry.


    It's inefficient in principle.
    In practice, I agree, it has no bearing on perceived performance.

    The fact that we are even having this discussion though does highlight that there is no 'perfect' solution to writing long literal strings in VB6.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    Re: Too many line continuations

    Thanks everyone, problem solved

  14. #14
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Too many line continuations

    Quote Originally Posted by RhinoBull
    and believe me quite often dynamic sql could be huge.
    Trust me, I have queries that go 10 times longer than that one.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  15. #15
    New Member
    Join Date
    Mar 2014
    Posts
    1

    Re: [RESOLVED] Too many line continuations

    Hi Xor83,
    Can you please tell me how did your issue got resolved?
    I tried string concatenations and line continuations, it is never getting resolved for me..

  16. #16
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,635

    Re: [RESOLVED] Too many line continuations

    You should not post in old threads.
    This thread is from 2007, and Xor83 hasn't been on the site since 2010, so you would most likely be waiting quite awhile for a response from that individual.
    Also, the resolve had to do with using too many line continuations, not with a query. Are you having the same problem, since what you "tried", doesn't seem applicable to not working. If you're using concatenations, then by definition the problem with too many line continuations has to be solved, since you should have no line continuations.

    Bottom line, you should have started a new thread. Perhaps a moderator can split this of to a new thread at some point. (and you should show what you are trying to do that is not working).

  17. #17
    New Member
    Join Date
    Apr 2014
    Posts
    1

    Re: [RESOLVED] Too many line continuations

    You can try IF statements as well.

  18. #18
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: [RESOLVED] Too many line continuations

    Quote Originally Posted by Praveen123 View Post
    Hi Xor83,
    Can you please tell me how did your issue got resolved?
    I tried string concatenations and line continuations, it is never getting resolved for me..
    I would think either example in post #4 or post #5 should work.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  19. #19
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: [RESOLVED] Too many line continuations

    Since this thread is almost 7 years old I'm going to close it. If you have any problem please create your own thread.
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width