Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 July 21st, 2003, 10:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default UPDATE code

Hi there

I've got an update statement which is throwing up an error on line 7. I'm hoping someone can help me with it - here is the code - any help would be greatly appreciated.

<%
    set con = server.createobject("ADODB.Connection")
    con.open Application("hp_ConnectionString")

    SQLUpdate = "UPDATE TVListings SET TVTime = " & request("ProgTime") & " AND TVDate = " & request.Form("ProgDate") & " AND Title = " & request.Form("ProgTitle") & " AND Channel = " & request.Form("ProgChannel")

    con.execute(SQLUpdate)

    response.redirect("listings.asp?ListingsID="& request("ListingsID") &"&cache="&server.URLEncode(Now))
%>

Line 7 is the code: con.execute(SQLUpdate)

The error that it gives me is:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '00'.

/secure/Listings/process_edit.asp, line 7


thanks in anticipation

Adam
 
Old July 21st, 2003, 01:16 PM
Friend of Wrox
 
Join Date: May 2003
Posts: 202
Thanks: 0
Thanked 1 Time in 1 Post
Default

I see two problems.

First you need quotes around your date and string values.

for example:
Code:
AND Title = '" & request.Form("ProgTitle") & "' AND...
Secondly, the first AND should be a WHERE.

It's always helpful when debugging SQL statements to include a
Code:
Response.Write SQLUpdate
statement before the execute. This will help you more easily see the syntax errors.

Bruce Luckcuck
Director, Applications & Support Services
Wiley Publishing, Inc.
 
Old July 29th, 2003, 04:27 AM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Adam H-W
 Hi there

I've got an update statement which is throwing up an error on line 7. I'm hoping someone can help me with it - here is the code - any help would be greatly appreciated.

<%
    set con = server.createobject("ADODB.Connection")
    con.open Application("hp_ConnectionString")

    SQLUpdate = "UPDATE TVListings SET TVTime = " & request("ProgTime") & " AND TVDate = " & request.Form("ProgDate") & " AND Title = " & request.Form("ProgTitle") & " AND Channel = " & request.Form("ProgChannel")

    con.execute(SQLUpdate)

    response.redirect("listings.asp?ListingsID="& request("ListingsID") &"&cache="&server.URLEncode(Now))
%>

Line 7 is the code: con.execute(SQLUpdate)

The error that it gives me is:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '00'.

/secure/Listings/process_edit.asp, line 7


thanks in anticipation

Adam
 
Old July 29th, 2003, 05:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Adam,
In UPDATE statement you have to use "," instead of AND, and be sure that you have quoted all string and date values:
SQLUpdate = "UPDATE TVListings SET TVTime = '" & request("ProgTime") & "',TVDate = '" & request.Form("ProgDate") & "',Title = " & request.Form("ProgTitle") & ",Channel = " & request.Form("ProgChannel")

...but the Soon is eclipsed by the Moon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample code please update it wozzle BOOK: Professional Microsoft SharePoint 2007 Workflow ISBN: 978-0-470-40251-1 1 October 27th, 2008 03:16 AM
Code for Update Casst Visual Studio 2005 0 May 23rd, 2007 09:29 AM
Update Code Not Working Odifius BOOK: Beginning Access VBA 0 September 19th, 2006 04:04 PM
code doesn't update database Lesviper Beginning VB 6 1 February 7th, 2005 10:18 AM





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