-
Aug 2nd, 2007, 08:57 AM
#1
Thread Starter
Lively Member
[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?
-
Aug 2nd, 2007, 09:00 AM
#2
Re: Too many line continuations
There are only 24 allowed and you obviously reached the limit.
-
Aug 2nd, 2007, 09:08 AM
#3
Thread Starter
Lively Member
Re: Too many line continuations
so what i have to do now?
-
Aug 2nd, 2007, 09:11 AM
#4
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.
-
Aug 2nd, 2007, 09:15 AM
#5
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
-
Aug 2nd, 2007, 09:25 AM
#6
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.
-
Aug 2nd, 2007, 09:50 AM
#7
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)) "
-
Aug 2nd, 2007, 09:53 AM
#8
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.
-
Aug 2nd, 2007, 09:59 AM
#9
Re: Too many line continuations
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.
-
Aug 2nd, 2007, 11:05 AM
#10
Re: Too many line continuations
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.
-
Aug 2nd, 2007, 10:03 AM
#11
Re: Too many line continuations
I didn't say it was a big deal, did I?
-
Aug 2nd, 2007, 10:10 AM
#12
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.
-
Aug 2nd, 2007, 10:14 AM
#13
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.
-
Aug 2nd, 2007, 10:22 AM
#14
Thread Starter
Lively Member
Re: Too many line continuations
Thanks everyone, problem solved
-
Mar 25th, 2014, 12:04 PM
#15
New Member
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..
-
Mar 25th, 2014, 12:16 PM
#16
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).
-
May 8th, 2014, 04:24 AM
#17
Re: [RESOLVED] Too many line continuations
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.
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.
https://get.cryptobrowser.site/30/4111672
-
May 7th, 2014, 12:06 PM
#18
New Member
Re: [RESOLVED] Too many line continuations
You can try IF statements as well.
-
May 8th, 2014, 09:03 AM
#19
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|