Forum Moderators: open

Message Too Old, No Replies

expected statement error in ASP

having trouble with end if statement

         

cherry

2:11 pm on Jun 3, 2003 (gmt 0)

10+ Year Member



hi guys

can you help with with this bit of code that I have done. It's a form where the user gives me all the info and it gets put into a database.

Problem is im new and trial and error is my moto but im getting into difficulty here. How should I end my asp page.

I have declared my dims
I have declared my fields on my form
I have told it what database it's to put the info
I have then closed my connection string.

I'm having trouble with the end if statement. I keep getting an error up saying

expected statement
line 67
end if

here's my code below.....can someone please advise me :-)

Thanks


Set cn = Server.CreateObject("ADODB.Connection")

cn.ConnectionString = connStr
cn.Open


sql="INSERT into tbl_monthdraw(title, f_name, s_name, address, town, county, country, postcode, home_telephone, "&_
"work_telephone, mobile, email, DOB,, gender, drink_bottle, when_drink, brands, other, contact, date_entered)"&_
"VALUES ('" & title & "', '" & f_name & "', '" & s_name & "', '" & address & " " & town & "', '" & county &_
"', '" & country & "', '" & postcode & "', '" & home_telephone & "', '" & work_telephone & "', '" & mobile &_
"', '" & email & "', '" & DOB & "', '" & gender &_
"', '" & drink_bottle & "', '" & when_drink & "', '" & brands & "', '" & other & "', '" & contact & "', getdate())"


cn.execute(sql)
Set cn = Nothing
end if
%>

<% Response.Redirect("../share/thanks.asp") %>

jimmykav

2:47 pm on Jun 3, 2003 (gmt 0)

10+ Year Member



Hi cherry

In the code you supplied I was unable to find an "IF" statement to match the End if

And "End if" statement must be accomapied by a preceeding "If xxxxx Then" statement.

If the code is not conditional then just remove the "End if"

cherry

3:01 pm on Jun 3, 2003 (gmt 0)

10+ Year Member



Thanks Jimmykav

you're right.....sometimes you just get something into your head and get tunnel vision.

i've taken the end if statement out and got a different error!

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ','.

/dev/script/process.asp, line 67

I must have a pesky ' somewhere I shouldn't have.....wish me luck finding it :-)

Thanks for you help

bmcgee

3:33 pm on Jun 3, 2003 (gmt 0)

10+ Year Member



"VALUES ('" & title & "', '" & f_name & "', '" & s_name & "', '" & address & " " & town & "', '" & county &_

Looks like it should be:
"VALUES ('" & title & "', '" & f_name & "', '" & s_name & "', '" & address & "', '" & town & "', '" & county &_

Xoc

4:15 pm on Jun 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The _ must be preceded by a space.

mattur

4:49 pm on Jun 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I must have a pesky ' somewhere...

Cherry, for debugging SQL statements I find it easiest to just response.write the SQL string (you can comment out the database objects) then copy the SQL string from your web page into your database to check syntax. HTH...

cherry

8:11 am on Jun 5, 2003 (gmt 0)

10+ Year Member



Thanks guys I got it sorted and it's all working beautifully :-)

I just have to be carefull and read everything twice so I don't miss any more commas!