Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 February 24th, 2005, 07:33 AM
Authorized User
 
Join Date: Sep 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL INSERT

Hi,

I'm having trouble inserting data into my access db.

I have 4 fields in my table:

id - Autonumber
title - memo
body - memo
date- date/time


here is my asp:
---------------------------------
set objcomm = server.createobject("adodb.command")
set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")

conString = "DBQ=" & Server.MapPath("db\blog.mdb")
objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & conString

title = request.form("title")
body = request.form("body")

objcomm.activeconnection = objConn
objcomm.commandtext = "INSERT INTO blog(title,body) VALUES ('" & title & "','" & body & "')"

objcomm.execute
-----------------------------------

And here is the error:


------------------------------
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''Chelsea were leading after Juliano Belletti deflected Damien Duff's cross into his own net after 32 minutes.Substitute Maxi Lopez quickly fired Barca level before Samuel Eto'o smashed in the winner with 17 minutes left. It was cruel luck on Chelsea, who had'.
/w00t/admin/add-action.asp, line 17
-----------------------------------------
 
Old February 24th, 2005, 07:37 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi,
use this line...

title = replace(request.form("title"),"'","''")
body = replace(request.form("body"),"'","''")

i think it will work fine

surendran
(Anything is Possible)
 
Old February 24th, 2005, 07:46 AM
Authorized User
 
Join Date: Sep 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the quick reply. works great.

I have one more question, I am trying to format the date:

<%=objRS(FormatDateTime(date,2))%>

But it does not work, am I doing it right?

Thanks for your help

 
Old February 24th, 2005, 07:56 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi,
i want to know why you are using like
<%=objRS(FormatDateTime(date,2))%>
please use like this
<%=FormatDateTime(Date, 1)%>

http://msdn.microsoft.com/library/de...atdatetime.asp

surendran
(Anything is Possible)





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Insert kavithaganesh SQL Language 1 September 26th, 2007 11:20 PM
INSERT SQL donevco Access 2 February 9th, 2007 06:37 PM
SQL Insert C# N4th SQL Server 2000 6 December 5th, 2006 05:28 AM
how to create insert sql aji SQL Language 4 June 23rd, 2005 06:41 PM
how to insert into SQL table p2ptolu Classic ASP Databases 1 June 17th, 2005 06:52 AM





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