Solved

Microsoft VBScript compilation error '800a0401'  Expected end of statement

Posted on 2016-09-12
15
53 Views
Last Modified: 2016-09-12
Hi All getting this bizare error... cannot figure it out
Set Header=oConn.Execute("SELECT * FROM codes WHERE code_live=TRUE ORDER BY RND(-10000000*TimeValue(Now())*code_ID)")

Open in new window

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/home2.asp, line 133

HeaderPic=SubDomain("brand_ID")&"-header-"&Header("code_short")&".jpg"
------------------------------------------^

Open in new window


ideas?
0
Comment
Question by:Graeme
  • 7
  • 5
  • 3
15 Comments
 
LVL 32

Expert Comment

by:Big Monty
ID: 41794315
Are SubDomain and Header recordset objects?

if you run the query directly in your database, do you get results back?

Can you provide a bit more code, maybe 10 lines worth before and after line 133?
0
 
LVL 82

Expert Comment

by:hielo
ID: 41794323
Are you sure the query is successful? Try:
On Error Resume Next
Set Header=oConn.Execute("SELECT * FROM codes WHERE code_live=TRUE ORDER BY RND(-10000000*TimeValue(Now())*code_ID)")
If Err.number<>0  Then
   Response.Write("SELECT query failed")
   Response.Write( Err.Description )
End If

Open in new window

0
 

Author Comment

by:Graeme
ID: 41794325
I have just run it in the database, it is showing up the objects that I expect (which is 3)

when I response.write(header("code_short")) is shows correct as well, its when I put it into a shortcut (HeaderPic=etc) is where the issue comes up

it was a direct cut and paste from one of my the older version of the same site, there is no difference code, database, tables, columns or data

will try your test code, brb
0
 

Author Comment

by:Graeme
ID: 41794327
exactly the same:
Microsoft VBScript compilation error '800a0401'

Expected end of statement

/home2.asp, line 138 (because of extra lines)

HeaderPic=SubDomain("brand_ID")&"-header-"&Header("code_short")&".jpg"
------------------------------------------^

Open in new window

0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41794331
can you provide additional code so I have some sort of context in the way you're using it?
0
 

Author Comment

by:Graeme
ID: 41794344
<%
	Set oConn=Server.CreateObject("ADODB.Connection")
	oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("core/allcore.mdb")
	If SubDomain("brand_ID")="GPT" Then
		Set Header=oConn.Execute("SELECT * FROM codes WHERE code_live=TRUE ORDER BY RND(-10000000*TimeValue(Now())*code_ID)")
		Response.Write(Header("code_short"))
		HeaderPic=SubDomain("brand_ID")&"-header-"&Header("code_short")&".jpg"
'	ElseIf SubDomain("brand_header")="rotate" Then
'		Set Header=oConn.Execute("SELECT * FROM site_menu WHERE brand_ID="&SubDomain("brand_ID")&" AND menu_live=TRUE ORDER BY RND(-10000000*TimeValue(Now())*menu)")
'		Response.Write(Header("menu"))
'		HeaderPic=SubDomain("brand_ID")&"-header-"&Header("menu")&".jpg"
'	ElseIf SubDomain("brand_header")="still" Then
'		HeaderPic=SubDomain("brand_ID")&"_header.jpg"
	End If
%>
<td width=1330 height=300 align=center valign=bottom colspan=2 background="http://members.amnet.net.au/~webber4/<%=HeaderPic%>" style="background-size:cover;background-position:center,center" rowspan=2>

Open in new window

0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41794371
are you sure Header("code_short") contains a value?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Graeme
ID: 41794420
yes Header("code_short") contains either WEC or F1 or MGP

the response.write above it shows that each time i use it and comment out HeaderPic
0
 
LVL 82

Expert Comment

by:hielo
ID: 41794428
try using the fully qualified path to the field value -- Header.Fields("code_short").Value :

<%
Dim HeaderPic
HeaderPic=""
	Set oConn=Server.CreateObject("ADODB.Connection")
	oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("core/allcore.mdb")
	If SubDomain("brand_ID")="GPT" Then
        On Error Resume Next
        Set Header=oConn.Execute("SELECT * FROM codes WHERE code_live=TRUE ORDER BY RND(-10000000*TimeValue(Now())*code_ID)")
        If Err.number<>0  Then
           Response.Write("SELECT query failed")
           Response.Write( Err.Description )
			Response.End
        End If
		
		'Response.Write(Header("code_short"))
		HeaderPic=SubDomain("brand_ID") & "-header-" & Header.Fields("code_short").Value & ".jpg"
'	ElseIf SubDomain("brand_header")="rotate" Then
'		Set Header=oConn.Execute("SELECT * FROM site_menu WHERE brand_ID="&SubDomain("brand_ID")&" AND menu_live=TRUE ORDER BY RND(-10000000*TimeValue(Now())*menu)")
'		Response.Write(Header("menu"))
'		HeaderPic=SubDomain("brand_ID")&"-header-"&Header("menu")&".jpg"
'	ElseIf SubDomain("brand_header")="still" Then
'		HeaderPic=SubDomain("brand_ID")&"_header.jpg"
	End If
%>
<td width=1330 height=300 align=center valign=bottom colspan=2 background="http://members.amnet.net.au/~webber4/<%=HeaderPic%>" style="background-size:cover;background-position:center,center" rowspan=2>

Open in new window

0
 

Author Comment

by:Graeme
ID: 41794436
same error...
Microsoft VBScript compilation error '800a0401'

Expected end of statement

/home2.asp, line 145

HeaderPic=SubDomain("brand_ID")&"-header-"&Header.Fields("code_short").Value&".jpg"
------------------------------------------^

Open in new window

0
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
ID: 41794505
the code looks fine to me. as long as you're getting values back from the recordset, I can't see where an error would occur.

is the block of code below in any sort of loop?

try the code below, I formatted it for readability, as well as tried a different approach.
<%
Dim HeaderPic
HeaderPic=""
dim brandID, codeShort

	Set oConn=Server.CreateObject("ADODB.Connection")
	oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("core/allcore.mdb")
	If SubDomain("brand_ID")="GPT" Then
        On Error Resume Next
        Set Header=oConn.Execute("SELECT * FROM codes WHERE code_live=TRUE ORDER BY RND(-10000000*TimeValue(Now())*code_ID)")
      		
		'Response.WriteHeader("code_short") 
                codeShort = Header("code_short")
		HeaderPic = SubDomain("brand_ID") _
                  & "-header-" _
                  & codeShort _
                  &".jpg"
                  if err.number <> 0 then response.write err.description
'	ElseIf SubDomain("brand_header")="rotate" Then
'		Set Header=oConn.Execute("SELECT * FROM site_menu WHERE brand_ID="&SubDomain("brand_ID")&" AND menu_live=TRUE ORDER BY RND(-10000000*TimeValue(Now())*menu)")
'		Response.Write(Header("menu"))
'		HeaderPic=SubDomain("brand_ID")&"-header-"&Header("menu")&".jpg"
'	ElseIf SubDomain("brand_header")="still" Then
'		HeaderPic=SubDomain("brand_ID")&"_header.jpg"
	End If
%>

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 41794506
The only other suggestions I can think of are:
a. Try declaring HeaderPic at the top (like in my post)
b. Try adding spaces around the ampersands (like in my post)
c. Verify that you are actually using double quotes (ascii code34) and not some "fancy double quote" (similar to what MS Word likes to use).  Try opening notepad, type your statement there, then do a cut and paste from notepad onto your code file.

Also, what is SubDomain() doing? If it is querying a db, make sure it returns an actual value (as in Header.Fields("code_short").Value ) and not an "object" (as in Header("code_short") )
0
 

Author Comment

by:Graeme
ID: 41794515
hielo

I copied and pasted your code directly, same error

Yes Subdomain is a query that definatley returns a value

as mentioned before this exact code that I posted was a clean cut and paste from the previous version of the site, no changes to data, table, columns nor code.

just no idea why it is erroring there, whilst the line before I can Reseponse.Write(Header("code_short")) and it gives a value no issues at all
0
 

Author Comment

by:Graeme
ID: 41794532
BigMonty - it works! no idea why it does, but it does!

how strange!
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41794551
excellent, glad I could help :)
1

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple Angular 2 login page 4 84
Basic JavaScript Question 3 38
Need to click button twice to get results 2 33
Form Submit falis 6 26
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now