Record Update ASP conn.Execute sql

Posted on 2008-10-29
Last Modified: 2013-12-07
For some reason it doesnt like my code:
I can Add and Delete Records from my table fine, but Update will n ot fly.
Any ideas?

Basically I am running the code that I revised based on the


<body><h2>Update Record</h2>


set conn=Server.CreateObject("ADODB.Connection")


conn.Open "D:\Performance Assurance Team\East_pmi.mdb"


if Request.form("Date Closed")="" then

  set rs=Server.CreateObject("ADODB.Recordset") "SELECT * FROM tblProactiveIssues WHERE CAC='" & cid & "'",conn


  <form method="post" action="RecordUpdate.asp">


  <%for each x in rs.Fields%>



  <td><input name="<>" value="<%=x.value%>"></td>




  <br /><br />

  <input type="submit" value="Update record">




  sql="UPDATE tblProactiveIssues SET"

  sql=sql & "Region='" & Request.Form("Region") & "',"

  sql=sql & "Date Added='" & Request.Form("Date Added") & "',"

  sql=sql & "CAC='" & Request.Form("CAC") & "',"

  sql=sql & "CKTID='" & Request.Form("CKTID") & "',"

  sql=sql & "ACNA='" & Request.Form("ACNA") & "',"

  sql=sql & "Customer='" & Request.Form("Customer") & "',"

  sql=sql & "Ticket Number='" & Request.Form("Ticket Number") & "',"

  sql=sql & "Ticket Source='" & Request.Form("Ticket Source") & "',"

  sql=sql & "Monitoring Source='" & Request.Form("Monitoring Source") & "',"

  sql=sql & "Date Closed='" & Request.Form("Date Closed") & "',"

  sql=sql & "Disposition Code='" & Request.Form("Disposition Code") & "',"

  sql=sql & "Summary='" & Request.Form("Summary") & "'"

  sql=sql & " WHERE CAC='" & cid & "'"

  'on error resume next

   'conn.Execute sql

  if err<>0 then

    response.write("No update permissions!")


   Response.Redirect "View.asp" 

    'response.write("Record " & cid & " was updated!")

  end if 

end if




Open in new window

Question by:vzdog
  • 4
  • 3
  • 2
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22833425
you have no space between SET and Region:
  sql="UPDATE tblProactiveIssues SET "
  sql=sql & " Region='" & Request.Form("Region") & "',"

Open in new window

LVL 82

Expert Comment

ID: 22833440
Do you get any runtime errors?

Also, I see:
"Date Added='" & Request.Form("Date Added") & "',"

is Date added a Date/Time Field? IF yes, then
 Request.Form("Date Added") needs to be in mm/dd/yyyy format

AND the value needs # instead of apostrophes:
"Date Added=#" & Request.Form("Date Added") & "#,"

Author Comment

ID: 22836872
Some of my fields are numeric & alpha combined so is there something I should be using to indicate as such?
Date added is a date so how would I specify the format within the code?
LVL 82

Expert Comment

ID: 22836913
numeric field values should NOT be enclosed in apostrophes
date field values  need to be enclosed in #
other values need to be enclosed in apostrophes

Update table Set aquisitionDate=#11/29/2008#, value=40000, condition='excellent' WHERE product_id=3
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails


Author Comment

ID: 22843412
What about when it is a combination of both in the same field?

Author Comment

ID: 22843429
Also I am getting an error:
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in UPDATE statement.
/PMI/RecordUpdate.asp, line 44

it is:

conn.Execute sql
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22844118
please response.write the value of sql variable before the execute, so you can inspect what goes wrong.

Author Comment

ID: 22844169
I have no idea what you are telling me to do..
LVL 82

Accepted Solution

hielo earned 500 total points
ID: 22844986
>>What about when it is a combination of both in the same field?
PD123456 or SHD2HH4

You need to look at the definition of your table and see if the field data type of your Table is numeric. You are focusing on the contents of your table. You need to focus on the definition of your table.

On another note, those are NOT numeric values. You can add numbers:

You cannot add: PD123456 + SHD2HH4

So that MUST be text field, in which case you need to enclose the values in apostrophes.

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious sideā€¦
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now