473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

why does this simple script doesn't work

Hi

I am trying to update a date field in my table but some how this simple code
does not work, I know the select work because if I write the fields, it will
show the data from the table but why the update does not work?
<%

Set ConnGallery = Server.CreateObject("ADODB.Connection")
ConnGallery.Open ConnectionString
Set cmdTemp = Server.CreateObject("ADODB.Command")

Set CmdUpdateAd = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT Ads.* FROM Ads WHERE Advertiser=0 "
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = ConnGallery
CmdUpdateAd.Open cmdTemp, , 1, 3

CmdUpdateAd.Fields("Ad_Expires") = " "
CmdUpdateAd.Update
CmdUpdateAd.Close

response.Write ("hej")

%>
Jul 19 '05 #1
3 3722
What "does not work" about it? Are you getting an error? Are there any
records where advertiser=0? Why are you creating a recordset for an update?
Is Ad_Expires a text column?
Do this

sSQL = "UPDATE [Ads] SET [Ad_Expires]='' WHERE [Advertiser]=0"
Set ConnGallery = Server.CreateObject("ADODB.Connection")
ConnGallery.Open ConnectionString
ConnGallery.Execute sSQL
ConnGallery.Close
Set ConnGallery = Nothing
Ray at work
"Julian" <ep****@shaw.ca> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
Hi

I am trying to update a date field in my table but some how this simple code does not work, I know the select work because if I write the fields, it will show the data from the table but why the update does not work?
<%

Set ConnGallery = Server.CreateObject("ADODB.Connection")
ConnGallery.Open ConnectionString
Set cmdTemp = Server.CreateObject("ADODB.Command")

Set CmdUpdateAd = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT Ads.* FROM Ads WHERE Advertiser=0 "
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = ConnGallery
CmdUpdateAd.Open cmdTemp, , 1, 3

CmdUpdateAd.Fields("Ad_Expires") = " "
CmdUpdateAd.Update
CmdUpdateAd.Close

response.Write ("hej")

%>

Jul 19 '05 #2

Thanks Ray.

I did as you suggested, made a new file like this:

<%@ LANGUAGE="VBSCRIPT" %>
<!--#INCLUDE FILE="../dataconn_inc.asp"-->
<!--#INCLUDE FILE="../config_inc.asp"-->

<%
' to put the date for all non-advertiser to blank.
sSQL = "UPDATE [Ads] SET [Ad_expires]='' WHERE [Advertiser]= 0"
Set ConnGallery = Server.CreateObject("ADODB.Connection")
ConnGallery.Open ConnectionString
ConnGallery.Execute sSQL
ConnGallery.Close
Set ConnGallery = Nothing
response.Write ("hej")

%>

run the code and it executes without any error, the problem is that
database do not get updated.
Advertiser is type YES/NO
Ad_Expires is short date
and both defined so, they can be emty. My connection is correct since I
can get all the rows listed when I write it.
Any idea?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3
If you try to set a date/time column to '' in Access, you will get a data
conversion error. I suggest either setting the date to something like
1/1/1900, or setting it to null, depending on which would work better in
your environment.

sSQL = "UPDATE [Ads] SET [Ad_expires]=#1/1/1900# WHERE [Advertiser]= 0"
or
sSQL = "UPDATE [Ads] SET [Ad_expires]=NULL WHERE [Advertiser]= 0"

Ray at work

"Julian Caine" <we*******@gentlemenworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

Thanks Ray.

I did as you suggested, made a new file like this:

<%@ LANGUAGE="VBSCRIPT" %>
<!--#INCLUDE FILE="../dataconn_inc.asp"-->
<!--#INCLUDE FILE="../config_inc.asp"-->

<%
' to put the date for all non-advertiser to blank.
sSQL = "UPDATE [Ads] SET [Ad_expires]='' WHERE [Advertiser]= 0"
Set ConnGallery = Server.CreateObject("ADODB.Connection")
ConnGallery.Open ConnectionString
ConnGallery.Execute sSQL
ConnGallery.Close
Set ConnGallery = Nothing
response.Write ("hej")

%>

run the code and it executes without any error, the problem is that
database do not get updated.
Advertiser is type YES/NO
Ad_Expires is short date
and both defined so, they can be emty. My connection is correct since I
can get all the rows listed when I write it.
Any idea?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
8
by: tooheys | last post by:
This may be to simple for the level of material I've already seen here, but nothing ventured. I have two web page linked from http://www.rhodeisland-aa.org/ricsmeetings/index.htm They are...
12
by: Fred Pacquier | last post by:
First off, sorry for this message-in-a-bottle-like post... I haven't been able to phrase my questions well enough to get a meaningful answer from Google in my research. OTOH, it is standard...
13
by: LRW | last post by:
Having a problem getting a onSubmit function to work, to where it popsup a confirmation depending on which radiobutton is selected. Here's what I have: function checkdel() { if...
6
by: leonat | last post by:
I have an asp.net webform. When I view the page in the web browser, the html is returned but not any asp code, i.e., " <% ... %> ". This same code works in the "old" asp page BUT NOT in...
4
by: namemattersnot | last post by:
Re, SCENARIO: User clicks a link and a javascript function creates dynamic content in <div id="content"></div> using: document.getElementById("content").innerHTML = something In the page's...
17
by: StevePBurgess | last post by:
A really simple script is driving me up the wall. I have a very simply facility on a website to allow the user to reorder items in a database table as she wishes by clicking a link that (in this...
5
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
My question is simple: How does one debug ASP Classic with Microsoft Visual Web Developer Express 2005 ("VWD")? Looming in the back of anyone's mind when you see a posting like this on any...
0
by: osin | last post by:
Hello everyone, I need to generate an XML file whose element would be an active link (triggering a PERL script). The only tool I've found which is capable of doing it is Xlink. The problem is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.