Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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 November 4th, 2004, 08:25 AM
Authorized User
 
Join Date: Jul 2004
Location: , , Ireland.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trying to update a date field

Hi,

I'm trying to use the UPDATE statement to update a date field in an Access database, but no matter what I do it doesn't work. :(

Here's the code :

Set objRS2 = Server.CreateObject("ADODB.Recordset")

strSQL2 = "UPDATE tblSubject SET Date = #4-Nov-2004# WHERE Subject = '" & strSubject & "'"

objRS2.Open strSQL2, strConnect

I just keep getting an error 'Syntax error in UPDATE Statement'. I've done searches online for how to update date fields, and have tried everything I've found, but no luck.

I can successfully update the Subject field, btw - it's just when I try to update the date that I run into problems.

Please help save what's left of my tattered sanity!!

Rgds,
Jennie.
 
Old November 4th, 2004, 08:40 AM
Authorized User
 
Join Date: Jul 2004
Location: , , Ireland.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, it eventually came to me in a flash of divine inspiration.

The field name 'Date' was causing the problem.

I currently owe the swear-box a fortune.

 
Old November 4th, 2004, 08:42 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey Jennie,

If you don't want to change the field name, you can just use [Date] in your query rather than Date.

HTH,

Chris
 
Old November 4th, 2004, 08:55 AM
Authorized User
 
Join Date: Jul 2004
Location: , , Ireland.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Chris!

That's handy, now I don't have to change code elsewhere that selects that field.

Jennie.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an auto update date field tmswenson MySQL 3 January 4th, 2006 03:12 PM
Update Date Field desireemm Access 1 October 16th, 2005 12:25 AM
Update city field based on zip field nganb SQL Server ASP 0 April 22nd, 2004 10:30 PM
Update a date field levinll SQL Language 1 January 16th, 2004 02:41 PM
SQL2000 Date/Time field update Lucian Ion Dreamweaver (all versions) 9 January 2nd, 2004 09:14 PM





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