English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm using a template for an asp page that takes data from a form and writes it to the database.
The form has many fields, and when I write them all in the SELECT statement, the statement runs onto two lines of code (I can't force it to be on one really long one)
When I run the form and click 'submit' i get an error:
"Unterminated string constant" which points to the end of the first line where the code wraps.

How can i wrap the code onto two lines? or how can I change the settings in Macromedia Dreamweaver so that it will not automatically wrap after a certain # of characters?

2007-03-06 05:01:55 · 2 answers · asked by jimbobbighouse 4 in Computers & Internet Programming & Design

2 answers

Your best bet is to put the SQL string into a variable and then just add to that variable. Fortunately in ASP, all variables are variant by default. This allows you to add more than 256 characters into the variable.
The error is actually coming because you are missing a quote or have an apostrophe in the SQL. If macromedia splits it up causing the lack of ending quotes, then use the variable as stated above. If you need an apostrophe, you must add a second right after it to allow the SQL to run.

EXAMPLE:

Wrapping Lines (with a variable):

theSQL = "SELECT id, first_name, last_name "
theSQL = theSQL & "FROM customers"
theSQL = theSQL & "WHERE id = " & 1

Fixing apostrophe problem:

theSQL = "SELECT id, first_name, last_name "
theSQL = theSQL & "FROM customers"
theSQL = theSQL & "WHERE name = " & "jone''s"
(That is a double apostrophe between the e and the s above.)

2007-03-06 05:17:31 · answer #1 · answered by jw_pcs 2 · 1 0

The wrapping in Dreamweaver isn't your problem. It's the termination of your strings. Do your strings contain a single quote (apostrophe)? That's a no-no.

I also suggest trying this:

sql = "SELECT * FROM database WHERE column = 'constant',"
sql = sql & "column2 = 'constant2', column3 = 'constant3'"

etc.

2007-03-06 05:06:53 · answer #2 · answered by Scotty Doesnt Know 7 · 0 0

fedest.com, questions and answers