[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?
Re: Too many line continuations
There are only 24 allowed and you obviously reached the limit. ;)
Re: Too many line continuations
so what i have to do now?
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.
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".......
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.
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)) "
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.
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.
Re: Too many line continuations
I didn't say it was a big deal, did I? :rolleyes: :rolleyes:
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.
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.
Re: Too many line continuations
Thanks everyone, problem solved :)
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.
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..
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).
Re: [RESOLVED] Too many line continuations
You can try IF statements as well.
Re: [RESOLVED] Too many line continuations
Quote:
Originally Posted by
Praveen123
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.
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.