Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 3rd, 2007, 10:26 PM
Authorized User
 
Join Date: Mar 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error: Expected end of statement

What's wrong with this that's causing my error:

"Microsoft VBScript compilation error '800a0401'

Expected end of statement

/test/search2.asp, line 22

if request.form("f_lastname") <> "" then
^"



sql = "SELECT * FROM names WHERE date_time <> '' " _
    if request.form("f_lastname") <> "" then
            & "and last_name = " & request.form("f_lastname")
    end if
==============

I've tried it a few different ways, but I keep getting the same error.

Thanks for the assistance!!


 
Old December 3rd, 2007, 10:31 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

A few things, compare the differences:

sql = "SELECT * FROM names WHERE date_time <> '' " & _
    if request.form("f_lastname") <> "" then
       sql = sql & " and last_name = " & request.form("f_lastname")& ";"
    end if

Is the field last_name a string? I suspect so, if so you will need extra single quotes. EG:

sql = "SELECT * FROM names WHERE date_time <> '' " & _
    if request.form("f_lastname") <> "" then
       sql = sql & " and last_name = '" & request.form("f_lastname") & "';"
    end if

Wind is your friend
Matt
 
Old December 3rd, 2007, 11:33 PM
Authorized User
 
Join Date: Mar 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Matt!!

I had tried what you said before I posted but I was getting the error. Now I know why. It was as you posted that I needed the single quote. The other thing I did change from you example was to take the & _ out from sql = "SELECT * FROM names WHERE date_time <> '' " & _. It now works perfect. :)

 
Old December 4th, 2007, 12:52 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Glad to hear - oooopss my apologies you are correct no need for the & _ sorry bout that

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
With Me .Show() I get error "end of statement exp kenn_rosie VS.NET 2002/2003 1 March 20th, 2006 09:12 PM
Expected end islandtiu BOOK: Beginning ASP 3.0 5 January 17th, 2006 10:19 AM
expected end of statement Adam H-W Classic ASP Databases 3 January 4th, 2005 05:37 AM
(0x800A03F6) Expected 'End' walrus Classic ASP Databases 5 April 15th, 2004 04:10 AM
expected end of statement....help.... chaoz83 Classic ASP Databases 3 September 23rd, 2003 01:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.