cant work out whats wrong with this code :(

W

woody22

Ive come up with an online room booking system which sends e mail vi
CDONTS fine but i get the following error message when i try to send t
a database too!! I cant for the life of me work out whats wrong with th
sql code ive done as ive used exactly the same code for another syste
and it works fine!! arghh!! Help Please!

Error Code


Code
-------------------
Microsoft VBScript compilation error '800a0401'

Expected end of statement

/Room_Bookings/bookingconfirmation.asp, line 35

& "'"&projector&"', '"&headphones&"', '"&support&"')"
----------------------^


-------------------



SQL CODE


Code
-------------------

<%

staffname=Replace(Request.Form("staffname"), "'", "''")
email=Replace(Request.Form("email"), "'", "''")
subject=Request.Form("subject")
classyear=Replace(Request.Form("classyear"), "'", "''")
date=Replace(Request.Form("date") , "'", "''")
periods=Replace(Request.Form("periods") , "'", "''")
projector=Request.Form("projector")
headphones=Request.Form("headphones")
support=Request.Form("support")

if staffname="" then staffname=" "
if email="" then email=" "
if subject="" then subject=" "
if classyear="" then classyear=" "
if date="" then date=" "

if periods="" then periods=" "
if projector="" then projector=" "
if headphones="" then headphones=" "
if support="" then support=" "



Set MyConn=Server.CreateObject("ADODB.Connection")
ConnStr="DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("roombookings.mdb")


SQL = "Insert Into bookingdetails (staffname, email, subject, " _
& "classyear, date, periods, " _
& "projector, headphones, support) Values ('"&staffname&"', '"&email&"', '"&subject&"', " _
& "'"&classyear&"', '"&date&"', '"&periods&"', " _
& "'"&projector&"', '"&headphones&"', '"&support&"')"


MyConn.Open connStr
MyConn.Execute (SQL)
MyConn.Close
Set MyConn = Nothing

%>
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

Add spaces around your ampersands. That should solve your problem. The
quickest method is doing a search and replace. Search for & and replace with
[space]&[space], where [space] means inserting a single space and not the
actual word [space].

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
L

Larry Bud

SQL = "Insert Into bookingdetails (staffname, email, subject, " _
& "classyear, date, periods, " _
& "projector, headphones, support) Values ('"&staffname&"',
'"&email&"', '"&subject&"', " _
& "'"&classyear&"', '"&date&"', '"&periods&"', " _
& "'"&projector&"', '"&headphones&"', '"&support&"')"

This is not the right way to go across lines in ASP. It's

sql="select * from " &_
"phonebook " &_
"order by last_name"
 
W

woody22

woody22 said:
*ill give this a try now :)! *

ive added spaces which seems to be working ok - however i get th
following error message now!! :(:(


Code
-------------------


Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

/Room_Bookings/bookingconfirmation.asp, line 38


-------------------


this is the full code


Code
-------------------

<%

staffname=Replace(Request.Form("staffname"), "'", "''")
email=Replace(Request.Form("email"), "'", "''")
subject=Request.Form("subject")
classyear=Replace(Request.Form("classyear"), "'", "''")
strdate=Replace(Request.Form("strdate") , "'", "''")
periods=Replace(Request.Form("periods") , "'", "''")
projector=Request.Form("projector")
headphones=Request.Form("headphones")
support=Request.Form("support")

if staffname="" then staffname=" "
if email="" then email=" "
if subject="" then subject=" "
if classyear="" then classyear=" "
if strdate="" then strdate=" "

if periods="" then periods=" "
if projector="" then projector=" "
if headphones="" then headphones=" "
if support="" then support=" "



Set MyConn=Server.CreateObject("ADODB.Connection")
ConnStr="DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("roombookings.mdb")

SQL = "Insert Into bookingdetails (staffname, email, subject, " _
& "classyear, strdate, periods, " _
& "projector, headphones, support) Values ('" & staffname & "', '" & email & "', '" & subject & "', " _
& "'" & classyear & "', '" & strdate & "', '" & periods & "', " _
& "'" & projector & "', '" & headphones & "', '" & support & "')"

MyConn.Open connStr
MyConn.Execute (SQL)
response.write
MyConn.Close
Set MyConn = Nothing


Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
Dim strBody
 
C

chris leeds

your database seems to not be marked "writable" you can use FrontPage to
make it "writable" even if you don't use FrontPage to get at it.
tools/ web settings/ database/ browse to the .mdb in question, hit add, hit
verify, hit OK.
that's it. your .mdb file will be "writable".

HTH

--
Chris Leeds,
Microsoft MVP FrontPage

The email address on this posting is a "black hole". I got tired of all the
spam.
Please feel free to contact me here:
http://nedp.net/contact/
--


woody22 said:
*ill give this a try now :)! *

ive added spaces which seems to be working ok - however i get the
following error message now!! :(:(


Code:
--------------------


Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

/Room_Bookings/bookingconfirmation.asp, line 38


--------------------


this is the full code


Code:
--------------------

<%

staffname=Replace(Request.Form("staffname"), "'", "''")
email=Replace(Request.Form("email"), "'", "''")
subject=Request.Form("subject")
classyear=Replace(Request.Form("classyear"), "'", "''")
strdate=Replace(Request.Form("strdate") , "'", "''")
periods=Replace(Request.Form("periods") , "'", "''")
projector=Request.Form("projector")
headphones=Request.Form("headphones")
support=Request.Form("support")

if staffname="" then staffname=" "
if email="" then email=" "
if subject="" then subject=" "
if classyear="" then classyear=" "
if strdate="" then strdate=" "

if periods="" then periods=" "
if projector="" then projector=" "
if headphones="" then headphones=" "
if support="" then support=" "



Set MyConn=Server.CreateObject("ADODB.Connection")
ConnStr="DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("roombookings.mdb")

SQL = "Insert Into bookingdetails (staffname, email, subject, " _
& "classyear, strdate, periods, " _
& "projector, headphones, support) Values ('" & staffname & "', '" &
email & "', '" & subject & "', " _
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top