|
|
 |
| 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.
|
 |

May 10th, 2005, 12:24 PM
|
|
Registered User
|
|
Join Date: May 2005
Location: , , USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 10th, 2005, 07:25 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,654
Thanks: 6
Thanked 4 Times in 4 Posts
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |