Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unterminated string constant: advise please 1

Status
Not open for further replies.

SteveHigh

Technical User
Jan 17, 2007
158
0
0
GB
Hello

I am getting an error message in a page which is supposed to show records in a table:

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/w3Test/addShow.asp, line 37

Response.Write("<tr><td>Full Name</td></td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr>
-----------------------------------------------------------------------------------------------------------------^

The code I have is:

Response.Write("<tr><td>Full Name</td></td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr>

Response.Write("<tr><td>" & TBL("FullName") & "</td><td>" & TBL("Sex") & "</td><td>" & TBL("Country") & "</td><td>" & TBL("Hobbies") & "</td><td>" & TBL("FavouritePerson") & "</td></tr>")

Thanks for any suggestions or ideas.

Cheers

Steve
 
You included the following code:
Response.Write("<tr><td>Full Name</td></td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr> which should be more like Response.Write("<tr><td>Full Name</td></td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr>"). You've left off the closing quotes. However, since your error message points to a location that doesn't make a lot of sense, it may be you have left out some quotes before this or added some inappropriately. Fix the problem above then try again. You may find your error is flagged at another location.

 
You don't have to stick everything on one line. You can split it over several lines using _ to indicate continuation
Code:
Response.Write("<tr><td>Full Name</td>" & _
   "<td>Sex</td>" & _ 
   "<td>Country</td>" & _
   "<td>Hobbies</td>" & _
   "<td>Favourite Person</td>" & _
   "</tr>").
It will also help you spot mistakes like <td>Full Name</td></td>Sex</td>
 
That's great, you both. I keep forgetting about the & _.

I saw the table formatting error this morning and have corrected the missing ") so that now I am able to add records to the table:


Is there a way of having the table as follows and not as I have it at the moment:

Full Name Sex Country Hobbies Person

Person1 Male UK Football Rooney
Person2 Female USA Baseball Davies
Person3 Female India Men R.Ich
Person4 Male Belize Swimming Kylie

Many thanks again for your help.

Steve
 
Good catch, xwb

Steve, I'm assuming you have a Do While Loop to pull the records and the creation of the first row is within that loop.

Something like...
Response write "<table>"
Do While Not RS.EOF
Response.Write("<tr><td>Full Name</td><td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr>")
Response.Write("<tr><td>" & TBL("FullName") & "</td><td>" & TBL("Sex") & "</td><td>" & TBL("Country") & "</td><td>" & TBL("Hobbies") & "</td><td>" & TBL("FavouritePerson") & "</td></tr>")
RS.movenext
Loop
Response.write "</table>"


As your current table displays, the header row is repeated with each record.

You can place the first row outside the loop...

Response write "<table>"
Response.Write("<tr><td>Full Name</td><td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr>")
Do While Not RS.EOF
Response.Write("<tr><td>" & TBL("FullName") & "</td><td>" & TBL("Sex") & "</td><td>" & TBL("Country") & "</td><td>" & TBL("Hobbies") & "</td><td>" & TBL("FavouritePerson") & "</td></tr>")
RS.movenext
Loop
Response.write "</table>"


 
Hello Molaker

Is this the While | MoveNext you mean? I have this:

<%
Dim DB, TBL
Set DB = Server.CreateObject("ADODB.Connection")
Set TBL = Server.CreateObject("ADODB.RecordSet")
DB.Mode = adModeReadWrite

DB.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\form.mdb;"

TBL.Open "Details" ,DB

Response.Write("<table border='1'>")
While NOT TBL.EOF

Response.Write("<tr><td>Full Name</td><td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr>")

Response.Write("<tr><td>" & TBL("FullName") & "</td><td>" & TBL("Sex") & "</td><td>" & TBL("Country") & "</td><td>" & TBL("Hobbies") & "</td><td>" & TBL("FavouritePerson") & "</td></tr>")

TBL.MoveNext
Wend
TBL.Close

Response.Write("<caption>Data entries</caption>")
Response.Write("</table>")
DB.Close
Set DB = Nothing
Set TBL = Nothing

%>


Yes, you're right. I do not want the header repeated every other row - looks silly.

Steve
 
Response.Write("<table border='1'>")
While NOT TBL.EOF

Response.Write("<tr><td>Full Name</td><td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr>")

Response.Write("<tr><td>" & TBL("FullName") & "</td><td>" & TBL("Sex") & "</td><td>" & TBL("Country") & "</td><td>" & TBL("Hobbies") & "</td><td>" & TBL("FavouritePerson") & "</td></tr>")

TBL.MoveNext
Wend
TBL.Close

Yes. Move the header line to before the While statement.

Response.Write("<table border='1'>")
Response.Write("<tr><td>Full Name</td><td>Sex</td><td>Country</td><td>Hobbies</td><td>Favourite Person</td></tr>")
While NOT TBL.EOF

Response.Write("<tr><td>" & TBL("FullName") & "</td><td>" & TBL("Sex") & "</td><td>" & TBL("Country") & "</td><td>" & TBL("Hobbies") & "</td><td>" & TBL("FavouritePerson") & "</td></tr>")

TBL.MoveNext
Wend
TBL.Close

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top