p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 10th, 2005, 12:24 PM
Registered User
 
Join Date: May 2005
Location: , , USA.
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old May 10th, 2005, 07:25 PM
Friend of Wrox
Points: 5,604, Level: 31
Points: 5,604, Level: 31 Points: 5,604, Level: 31 Points: 5,604, Level: 31
Activity: 40%
Activity: 40% Activity: 40% Activity: 40%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax error in INSERT INTO statement Stephan BOOK: Beginning JavaScript 16 February 22nd, 2005 01:43 PM
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 evol77 ASP.NET 1.1 2 December 17th, 2004 06:15 AM
Syntax error in INSERT INTO statement. askaggs Classic ASP Databases 5 June 10th, 2004 01:21 AM
Syntax error in INSERT INTO statement sankar ASP.NET 1.1 9 May 20th, 2004 03:48 PM



All times are GMT -4. The time now is 11:12 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc