PC Review


Reply
Thread Tools Rate Thread

cant work out whats wrong with this code :(

 
 
woody22
Guest
Posts: n/a
 
      2nd Aug 2004

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

%>


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


-
woody2
-----------------------------------------------------------------------
Posted via http://www.forum4designers.co
-----------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message103085.htm

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\) [MVP]
Guest
Posts: n/a
 
      2nd Aug 2004
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!
************************************************
"woody22" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Ive come up with an online room booking system which sends e mail via
> CDONTS fine but i get the following error message when i try to send to
> a database too!! I cant for the life of me work out whats wrong with the
> sql code ive done as ive used exactly the same code for another system
> 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
>
> %>
>
>
> --------------------
>
>
>
>
> --
> woody22
> ------------------------------------------------------------------------
> Posted via http://www.forum4designers.com
> ------------------------------------------------------------------------
> View this thread: http://www.forum4designers.com/message103085.html
>



 
Reply With Quote
 
Larry Bud
Guest
Posts: n/a
 
      2nd Aug 2004
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"
 
Reply With Quote
 
woody22
Guest
Posts: n/a
 
      3rd Aug 2004

ill give this a try now !



--
woody22
------------------------------------------------------------------------
Posted via http://www.forum4designers.com
------------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message103085.html

 
Reply With Quote
 
woody22
Guest
Posts: n/a
 
      3rd Aug 2004

woody22 wrote:
> *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


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


-
woody2
-----------------------------------------------------------------------
Posted via http://www.forum4designers.co
-----------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message103085.htm

 
Reply With Quote
 
chris leeds
Guest
Posts: n/a
 
      3rd Aug 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> woody22 wrote:
> > *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 & "', " _
> & "'" & 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
>
>
> --------------------
>
>
>
>
> --
> woody22
> ------------------------------------------------------------------------
> Posted via http://www.forum4designers.com
> ------------------------------------------------------------------------
> View this thread: http://www.forum4designers.com/message103085.html
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
whats wrong with my code =?Utf-8?B?YmFsdQ==?= Microsoft Access Form Coding 3 13th Jun 2007 07:44 AM
Whats wrong with my code? Adam@nospam.com Microsoft Access 7 27th Mar 2006 11:21 AM
Whats wrong with this code AMDGUY [MCP] Microsoft Access 2 7th Feb 2005 06:08 PM
hi, whats wrong with my code???? Norbert Lünow Microsoft Access 1 17th Aug 2004 11:47 AM
Whats wrong with this code?? SR Microsoft Access VBA Modules 6 13th Sep 2003 11:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:10 AM.