tags:

views:

57

answers:

2

Hi there,

I'm getting the following error on my site;

Microsoft VBScript compilation error '800a03f2'

Expected identifier

/includes/pagecontent.asp, line 2

Public Class Article
-------^

The above include is referenced in my page as follows;

<%
    Dim article : Set article = GetArticle(22)
%>
<!--#include virtual="/includes/pagecontent.asp" -->

<h1><%=article.Title%></h1>
<div><%=article.Content%></div>

I was wondering if anyone might be able to help me resolve this one? I've read a few posts about changing virtual to file, but this is not useful for me in my site structure.

The pagecontent.asp looks like this;

Public Class Article
    public ID
    public Title
    public Content
End Class

Function GetArticle(article)

    Dim conn: Set conn = Server.CreateObject("ADODB.connection") 
    conn.Open Application("database") 

    Dim cmd: Set cmd = Server.CreateObject("ADODB.command") 
    Dim rsArticle
    cmd.ActiveConnection = conn 
    cmd.CommandType = adCmdStoredProc 
    cmd.CommandText = "prc_getArticle" 
    cmd.Parameters.Append cmd.CreateParameter("@ArticleID", adInteger, adParamInput,, article) 
    Dim rsArticle: Set rsArticle = cmd.Execute 

    IF Not rsArticle.EOF Then
       Set GetArticle = new Article;

       GetArticle.ID = rsArticle.fields("art_id") 
       GetArticle.Title  = rsArticle.fields("art_title") 
       GetArticle.Content  = rsArticle.fields("art_content")  
    Else
       Set GetArticle = Nothing
    End If

    rsArticle.Close() 
End Function
+1  A: 

Little while since I've done ASP, but try the following, it might work or throw more light on the error:

<%Option Explicit%>
<!--#include virtual="/includes/pagecontent.asp" --> 
<% 
    Dim article : Set article = GetArticle(22) 
%> 

<h1><%=article.Title%></h1> 
<div><%=article.Content%></div>

I think the error is a false report, with the Dim article line causing the problem, but the error reported is falling into the include statement.

Paul Hadfield
Hey Paul. Looks like you're right. Made the changes you described and I now get the following error;<pre><code>Microsoft VBScript compilation error '800a0411'Name redefined/includes/pagecontent.asp, line 19Dim rsArticle: Set rsArticle = cmd.Execute----^</code></pre>
Neil Bradley
That's because you have a `Dim rsArticle` near the top of your function, and then a `Dim rsArticle: ...` farther in. Remove one or the other.
cHao
@cHao - Removed the Dim rsArticle on line 14 of pagecontent.asp. But now get; Microsoft VBScript compilation error '800a0411'Name redefined/delivery/index.asp, line 6Dim article : Set article = GetArticle(22)----^
Neil Bradley
@Neil Bradley: VBScript is not case sensitive. Meaning it might be getting confused about 'article' (the variable) vs 'Article' (the type name). I haven't worked with VBScript in ages, so i don't remember whether types and variables and functions etc have different namespaces, but it seems likely that they don't.
cHao
@cHao - You were right. Changed all references of 'article' to 'myarticle'. Thank you everyone for your help.
Neil Bradley
+3  A: 

In VBScript, classes don't have the "Public" keyword -- that's used for declaring variables inside a class, but classes themselves are implicitly public, and can't be declared with an access modifier.

cHao
+1, but it would be more accurate to say that a class in VBScript cannot ever be declared public (or private for that matter). You can declare variables, properties, functions and subprocedures for public/private, but not classes.
Tchami
@Tchami: good point. Updated.
cHao