Microsoft VBScript compilation (0x800A0400): Expected statement

Discussion in 'ASP General' started by Matt, Jan 11, 2004.

  1. Matt

    Matt Guest

    When the ASP statement end with a _ character, then the next line cannot
    have comment ' character. Is that correct? Since I encountered the following
    error:

    Microsoft VBScript compilation (0x800A0400)
    Expected statement

    sqlStmt = "insert into TimeSlot (WeekDay, BeginTime, EndTime) VALUES (" _
    ' & 2 & "," _
    & beginhour & "," _
    & tohour & ");"
     
    Matt, Jan 11, 2004
    #1
    1. Advertisements

  2. Matt

    Ray at Guest

    Did you copy and paste that code? It shouldn't give that error. The next
    line can start with a ', but all the lines that follow it with the _
    character will be a continuation of the comment, not code.

    Ray at home
     
    Ray at, Jan 11, 2004
    #2
    1. Advertisements

  3. Matt

    Roland Hall Guest

    :
    : When the ASP statement end with a _ character, then the next line cannot
    : have comment ' character. Is that correct? Since I encountered the
    following
    : error:
    :
    : Microsoft VBScript compilation (0x800A0400)
    : Expected statement
    :
    : sqlStmt = "insert into TimeSlot (WeekDay, BeginTime, EndTime) VALUES ("
    _
    : ' & 2 & "," _
    : & beginhour & "," _
    : & tohour & ");"

    It is an append to the next line.

    good:
    Response.Write("First line<br />" & vbCrLf & _
    "Second line<br />" & vbCrLf)
    result:
    First line
    Second line

    bad:
    Response.Write("First line<br />" & vbCrLf _
    Response.Write("Second line<br /> & vbCrLf)
    result:
    Microsoft VBScript compilation error '800a03ee'
    Expected ')'
    Response.Write("Second line<br />" & vbCrLf)
    --------------------------------------------^

    This will give you an error because it says you need a closing ).
    So, if you change it to this:
    Response.Write("First line<br />" & vbCrLf _
    Response.Write("Second line<br /> & vbCrLf))

    You'll get an interesting result:
    Second line
    First line

    If you're going to append lines, then it should follow as you would write it
    on one line. Your SQL statement is not finished and you cannot put a
    comment in the middle of it.

    This also is incorrect.

    sqlStmt = "insert into TimeSlot (WeekDay, BeginTime, EndTime) VALUES (" _
    ' & 2 & "," _
    & beginhour & "," _
    & tohour & ");"

    The thing to do it comment out the whole statement and just use a new
    statement with the part you want to remove.
    'sqlStmt = "insert into TimeSlot (WeekDay, BeginTime, EndTime) VALUES (" _
    ' & 2 & "," _
    ' & beginhour & "," _
    ' & tohour & ");"

    sqlStmt = "insert into TimeSlot (WeekDay, BeginTime, EndTime) VALUES (" _
    & beginhour & "," _
    & tohour & ");"

    The only thing wrong now is you need to remove Weekday since you have 3
    columns and only 2 values. (O:=
    And, it should probably be more like this:

    sqlStmt = "INSERT INTO TimeSlot(BeginTime, EndTime) VALUES(" _
    & beginhour & ", " _
    & tohour & ")"

    If the values were strings '12PM' instead of numbers '12', then you'll want
    quotes around the values:

    sqlStmt = "INSERT INTO TimeSlot(BeginTime, EndTime) VALUES('" _
    & beginhour & "', "' _
    & tohour & "')"

    --
    Roland

    This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose.
    -Technet Knowledge Base-
    http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0
    -Technet Script Center-
    http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
    -MSDN Library-
    http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Jan 11, 2004
    #3
  4. Matt

    Rob Greene Guest

    I think the issue here is that because the second line is commented, the
    '_' continuation for the third line is not seen. It's just part of the
    second line's comment!

    -rwg
     
    Rob Greene, Jan 11, 2004
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.