...

View Full Version : expected end of statement.



robojob
03-17-2006, 04:16 PM
i have this code: what its meant to do is recieve the variable entered into the date field on a form and then post to this script and then lookup the id number corresponding to this date and insert that id number into another table.

When you run this script we get error:

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/testing/add.asp, line 27, column 23



<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("bookings.mdb") & ";"
objConn.Open

DIM mySQL
date1 = Request.Form("date1")
mySQL = "SELECT cal.id where cal.date = " & date1 & " ;"

DIM objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn

'declare your variables
Dim date1, roombooked1, from1, to1, name1, eventname1, address1, phone1, price1, equipment1, layout1, caretaking1, insurance1, riskass1, other1, start1, end1, invnum1
Dim sConnString, connection, sSQL
'Receiving values from Form, assign the values entered to variables
date1 = Response.Write objRS("cal.id")
roombooked1 =Request.Form("roombooked")
from1 =Request.Form("from")
to1 =Request.Form("to")
name1 =Request.Form("name")
eventname1 =Request.Form("eventname")
address1 =Request.Form("address")
phone1 =Request.Form("phone")
price1 =Request.Form("price")
equipment1 =Request.Form("equipment")
layout1 =Request.Form("layout")
caretaking1 =Request.Form("caretaking")
insurance1 =Request.Form("insurance")
riskass1 =Request.Form("riskass")
other1 =Request.Form("other")
start1 =Request.Form("start1")
end1 =Request.Form("end1")
invnum1 =Request.Form("invnum1")

'declare SQL statement that will query the database
sSQL = "INSERT into bookings (date1, roombooked1, name1, eventname1, address1, phone1, price1, equipment1, layout1, caretaking1, insurance1, riskass1, other1, start1, end1, invnum1) values ('" & _
date1 & "', '" & roombooked1 & "', '" & name1 & "', '" & eventname1 & "', '" & address1 & "', '" & phone1 & "', '" & price1 & "', '" & equipment1 & "', '" & layout1 & "', '" & caretaking1 & "', '" & insurance1 & "', '" & riskass1 & "', '" & other1 & "', '" & start1 & "', '" & end1 & "', '" & invnum1 & "')"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("bookings.mdb")
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")

'Open the connection to the database
connection.Open(sConnString)

'execute the SQL
connection.execute(sSQL)

response.redirect "main.asp"
'Done. Close the connection object
connection.Close
Set connection = Nothing
%>
</body>
</html>

degsy
03-17-2006, 04:41 PM
date1 = Response.Write objRS("cal.id")

robojob
03-17-2006, 04:43 PM
that means nothing.... is that wrong?

degsy
03-20-2006, 06:32 PM
Look at your code and you'll find out.

robojob
03-21-2006, 08:59 AM
well i dont see anythin wrong unless you cant use a response.write in that location. if not how else can i do it?

degsy
03-21-2006, 04:22 PM
date1 = Response.Write objRS("cal.id")
roombooked1 =Request.Form("roombooked")

It is invalid syntax to assign a variable and response.write at the same time.

I'm not sure what you are trying to do
date1 = objRS("cal.id") ???
date1 = Request.Form("...") ???



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum