p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: End of Line


Message #1 by "Nadia Hamza" <hamzan@h...> on Wed, 6 Dec 2000 19:56:46 -0000
Hi,



Sometimes I 've got some very long SQL statements and I don't want to put

them all on one line.  I try an add "_" at the end of a line but if I do

this then I get unterminated string constant.  How can I continue a SQL

statement on another line. Thanks for your help.



Nadia

Message #2 by Kat Howlett <kat.howlett@c...> on Thu, 7 Dec 2000 11:43:01 +1100
Here is some code of mine where I have done just that :



	set contactform = Server.Createobject ("ADODB.connection")

	contactform.open "DSN=CompanyInformation"



		contactdata = "INSERT INTO ContactDetails"

		contactdata = contactdata

&"(CompanyName,FirstName,LastName,"

		contactdata = contactdata

&"Position,EmailAddress,TelephoneNumber,"

		contactdata = contactdata

&"FaxNumber,PostalAddress,StreetAddress,"

		contactdata = contactdata &"Directions,WebPage)"



		contactdata = contactdata & "VALUES"

		contactdata = contactdata &

"('"&company&"','"&fname&"','"&lname&"',"

		contactdata = contactdata &

"'"&position&"','"&email&"','"&telephone&"',"

		contactdata = contactdata &

"'"&fax&"','"&postal&"','"&street&"',"

		contactdata = contactdata & "'"&directions&"','"&web&"');"



		contactform.Execute (contactdata)



	contactform.Close

	Set contactform = Nothing



Kat



 -----Original Message-----

From: 	Nadia Hamza [mailto:hamzan@h...] 

Sent:	Thursday, 7 December 2000 6:57 AM

To:	ASP Databases

Subject:	[asp_databases] End of Line



Hi,



Sometimes I 've got some very long SQL statements and I don't want to put

them all on one line.  I try an add "_" at the end of a line but if I do

this then I get unterminated string constant.  How can I continue a SQL

statement on another line. Thanks for your help.



Nadia



Message #3 by "Oleg Perepelkin" <operep@m...> on Thu, 7 Dec 2000 13:08:13 +1000
> Sometimes I 've got some very long SQL statements and I don't want to put

> them all on one line.  I try an add "_" at the end of a line but if I do

> this then I get unterminated string constant.  How can I continue a SQL

> statement on another line. Thanks for your help.



Nadia, how about this syntax:



mySQL= "SELECT * " &_

                " FROM MEMBERS" &_

                " ORDER BY Name"

            ' etc.. 

Regards

Oleg



Message #4 by "Oleg Perepelkin" <operep@m...> on Thu, 7 Dec 2000 13:14:59 +1000
Nadia, sorry for previous memo, forgot to put space between & and _.

> Sometimes I 've got some very long SQL statements and I don't want to put

> them all on one line.  I try an add "_" at the end of a line but if I do

> this then I get unterminated string constant.  How can I continue a SQL

> statement on another line. Thanks for your help.



Nadia, how about this syntax:



mySQL= "SELECT * " & _

                " FROM MEMBERS" & _

                " ORDER BY Name"

            ' etc.. 

Regards

Oleg





Message #5 by "Arbon Reimer" <arbon_reimer@h...> on Wed, 6 Dec 2000 22:19:11 -0700
Make sure that you've got an & _ at the end of the line...

I am not sure that something like this works...

strSQL = "Insert into sometable(col1,col2)" _

strSQL = strSQL & "values('blah','blah')"



I believe it should read

strSQL = "Insert into sometable(col1,col2)" & _

strSQL = strSQL & " values('blah','blah')"



HTH

-Arbon Reimer

Message #6 by "Harsh Nandu" <harsh_stgil@h...> on Thu, 07 Dec 2000 06:21:34 -0000
strSQL="select * " _

        & " from table_nm" _

        & " where ..."





>From: "Nadia Hamza" <hamzan@h...>

>Reply-To: "ASP Databases" <asp_databases@p...>

>To: "ASP Databases" <asp_databases@p...>

>Subject: [asp_databases] End of Line

>Date: Wed, 6 Dec 2000 19:56:46 -0000

>

>Hi,

>

>Sometimes I 've got some very long SQL statements and I don't want to put

>them all on one line.  I try an add "_" at the end of a line but if I do

>this then I get unterminated string constant.  How can I continue a SQL

>statement on another line. Thanks for your help.

>

>Nadia

>

Message #7 by "Mike H." <mhaining@p...> on Thu, 7 Dec 2000 16:24:31 -0000
This is close, but not quite. You can do it in one of two ways.

1. If you want to use the line continuation:

   strSQL = "Insert into sometable (col1, col2)" & _

      " values ('blah', 'blah')"

2. If you want to concatenate to the end of a string:

   strSQL = "Insert into sometable (col1, col2)"

   strSQL = strSQL & " values ('blah', 'blah')"

Mike



> Make sure that you've got an & _ at the end of the line...

> I am not sure that something like this works...

> strSQL = "Insert into sometable(col1,col2)" _

> strSQL = strSQL & "values('blah','blah')"

> 

> I believe it should read

> strSQL = "Insert into sometable(col1,col2)" & _

> strSQL = strSQL & " values('blah','blah')"

> 

> HTH

> -Arbon Reimer


  Return to Index