Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2005, 11:24 AM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kingleon
Default Syntax error in INSERT INTO statement.

Hi,
I'm trying to add this fields to an access db, but I get this error.

Insert into tb_blackhistorymonth (ProgramTitle, Coordinator, Events, EventTime, Location, Contact, Summary, ) VALUES ('q', 'sdadssa', 'gfsdfgf', 'fdsgf', 'gsdfgsdf', ##, #5:00 PM# )
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

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

Here is my code.
Please advice.





<%
Dim sSQL
Dim strProgramTitle
Dim strCoordinator
Dim strEvents
Dim strEventtime
Dim strLocation
Dim strContact
Dim strSummary
Dim strSubmitted
Dim errMsg

strProgramTitle = Request.Form("ProgramTitle")
strCoordinator = Request.Form("Coordinator")
strEvents = Request.Form("Events")
strEventtime = Request.Form("Eventtime")
strLocation = Request.Form("Location")
strContact = Request.Form("Contact")
strSummary = Request.Form("Summary")
strSubmitted = Request.Form("Submitted")

'declare your variables
'dim connection
'dim sSQL, sConnString

call OpenDB(strdb, db)

'declare SQL statement that will query the database
    sSQL = "Insert into tb_blackhistorymonth ("
    sSQL = sSQL & "ProgramTitle, "
    sSQL = sSQL & "Coordinator, "
    sSQL = sSQL & "Events, "
    sSQL = sSQL & "EventTime, "
    sSQL = sSQL & "Location, "
    sSQL = sSQL & "Contact, "
    sSQL = sSQL & "Summary, "
    'sSQL = sSQL & "Submitted, "
    sSQL = sSQL & " ) VALUES ("
    'sSQL = sSQL & "FALSE, "
    sSQL = sSQL & "'" & trim(CheckString(strProgramTitle)) & "', "
    sSQL = sSQL & "'" & trim(CheckString(strCoordinator)) & "', "

    sSQL = sSQL & "'" & trim(CheckString(strLocation)) & "', "
    sSQL = sSQL & "'" & trim(CheckString(strContact)) & "', "
    sSQL = sSQL & "'" & trim(CheckString(strSummary)) & "', "
    sSQL = sSQL & "#" & trim(CheckString(strEvents)) & "#, "
    sSQL = sSQL & "#" & trim(CheckString(strEventTime)) & "# "

    'sSQL = sSQL & " #" & trim(CheckString(strSubmitted)) & "# "
    sSQL = sSQL & ")"

    response.write (sSQL)
    'do the deed
    'send it off
    cnndb.execute(sSQL)

'execute the SQL
'connection.execute(sSQL)

response.write "The data was inserted successfully."
   cnndb.close
'close the object and free up resources
'Connection.Close
Set cnndb = Nothing

%>


Thank you
Kingleon

 
Old May 10th, 2005, 06:25 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

There are a few things wrong with your statement:

1.. SQL statements need to be strings: "INSERT INTO..."
2.. Need to assign the string to a variable sql="INSERT INTO..."
3.. No need for a commer after the last field name: Summary, )
4.. It is good practice to finish all queries with a trailing semi colon: ...);"
5.. I dont believe you can do this: , ##,

Anyhow try this:
sql = "INSERT INTO tb_blackhistorymonth (ProgramTitle, Coordinator, Events, EventTime, Location, Contact, Summary ) VALUES ('q', 'sdadssa', 'gfsdfgf', 'fdsgf', 'gsdfgsdf', '', '#5:00:00 PM#' );"

Comments:
Why enter an empty string (where you had the ##) - allow nulls.
BTW: Since I can not see your field data types there is no garantee it will work.


Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax error in INSERT INTO statement mega ASP.NET 1.0 and 1.1 Basics 3 January 12th, 2005 04:30 PM
Syntax error in INSERT INTO statement. askaggs Classic ASP Databases 5 June 10th, 2004 12:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.