开发者

Expected Identifier in Public Class

开发者 https://www.devze.com 2023-01-11 18:01 出处:网络
I\'m getting the following error on my site; Microsoft VBScript compilation error \'800a03f2\' Expected identifier

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 i开发者_开发问答s 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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消