Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
help - cant work out whats wrong with this code!!
Old 07-09-2004, 10:18 AM help - cant work out whats wrong with this code!!
Experienced Talker

Posts: 37
Trades: 0
Ive got a confirmation asp page and get the following error:

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

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

/AbsenceForm/ConcernRecorded.asp, line 47

Below is the code this refers to - whats wrong i cant work it out?? Thanks

Woody


<%

MyYear=Replace(Request.Form("MyYear"), "'", "''")
MyName=Replace(Request.Form("MyName"), "'", "''")
MyTeacherName=Request.Form("MyTeacherName")
MyTeacherDept=Replace(Request.Form("MyTeacherDept" ), "'", "''")
MyDateIncident=Replace(Request.Form("MyDateInciden t") , "'", "''")
MyTimeIncident=Replace(Request.Form("MyTimeInciden t") , "'", "''")
MyDetailsIncident=Request.Form("MyDetailsIncident" )

if MyYear="" then MyYear=" "
if MyName="" then MyName=" "
if MyTeacherName="" then MyTeacherName=" "
if MyTeacherDept="" then MyTeacherDept=" "
if MyDateIncident="" then MyDateIncident=" "
if MyTimeIncident="" then MyTimeIncident=" "
if MyDetailsIncident="" then MyDetailsIncident=" "


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


SQL = "Insert Into TblMain (Year, Name, Teacher Name, " _
& "Teacher Dept, Incident Date, Incident Time, " _
& "Incident Details) Values ('"&MyYear&"', '"&MyName&"', '"&MyTeacherName&"', " _
& "'"&MyTeacherDept&"', '"&MyDateIncident&"', '"&MyTimeIncident&"', " _
& "'"&MyDetailsIncident&"')"


MyConn.Open connStr
MyConn.Execute (SQL)
MyConn.Close
Set MyConn = Nothing
woody22 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-09-2004, 10:35 AM
witchblade32's Avatar
Super Talker

Posts: 140
Location: Lititz, PA
Trades: 0
It may not be the only problem, my asp/access is really rusty, but spaces in field names is just asking for trouble. Surround field names that contain spaces with square brackets.

Code:
SQL = "Insert Into TblMain (Year, Name, [Teacher Name], " _
& "[Teacher Dept], [Incident Date], [Incident Time], " _
& "[Incident Details]) Values ('"&MyYear&"', '"&MyName&"', '"&MyTeacherName&"', " _
& "'"&MyTeacherDept&"', '"&MyDateIncident&"', '"&MyTimeIncident&"', " _
& "'"&MyDetailsIncident&"')"
witchblade32 is offline
Reply With Quote
View Public Profile Visit witchblade32's homepage!
 
Old 07-13-2004, 03:51 PM
wbmstr2good's Avatar
Average Talker

Posts: 22
Trades: 0
Just a glance, but your error may be caused by having spaces in the names of your column headers in the SQL statement. Give it a check.
wbmstr2good is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to help - cant work out whats wrong with this code!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12102 seconds with 12 queries