473,385 Members | 1,888 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.

how to populate empty field

this has been driving me nuts for over an hour now.

I have a DB with a date field that is empty

Because of this the records sometimes get included in searches because their
contents are less than a particular search.

so..I had planned to populate them with any old date.

BUT I CAN'T!!!

I have tried all sorts..and nothing seems to work..

including

dim checkseperator
checkseperator = mid(rs("creation_date"), 3, 1) ' this will give "/" if the
field contains a date - 01/01/2001 etc
if checkseperator <> "/" then
rs("creation_date") = date()
rs.update

this does nothing, field remains empty

also tried

dim testforlength
testforlength len(rs("creation_date"))
if testforlength < "1" then
rs("creation_date") = date()
rs.update

nothing!!

even tried

dim testforbytelength
testforbytelength = lenB(rs("creation_date"))
if testforbytelength < "1" then
rs("creation_date") = date()
rs.update

again....nothing!!!

I did a response.write of the lenB of the fields..if it contains a date the
result is 20..if it contains nothing then result isn't 0 as I expected..it's
just blank

maybe this has something to do with strings instead of numbers but I just
can't get my head round it!!!

please help me...or just kill me

thanks


Jul 19 '05 #1
8 1842
Alistair wrote:
this has been driving me nuts for over an hour now.

I have a DB with a date field that is empty

Because of this the records sometimes get included in searches
because their contents are less than a particular search.

so..I had planned to populate them with any old date.

BUT I CAN'T!!!

I have tried all sorts..and nothing seems to work..

including

dim checkseperator
checkseperator = mid(rs("creation_date"), 3, 1) ' this will give "/"
if the field contains a date - 01/01/2001 etc
if checkseperator <> "/" then
rs("creation_date") = date()
rs.update

this does nothing, field remains empty

also tried

dim testforlength
testforlength len(rs("creation_date"))
if testforlength < "1" then
rs("creation_date") = date()
rs.update

nothing!!

even tried

dim testforbytelength
testforbytelength = lenB(rs("creation_date"))
if testforbytelength < "1" then
rs("creation_date") = date()
rs.update

again....nothing!!!

I did a response.write of the lenB of the fields..if it contains a
date the result is 20..if it contains nothing then result isn't 0 as
I expected..it's just blank

maybe this has something to do with strings instead of numbers but I
just can't get my head round it!!!

please help me...or just kill me

thanks

UPDATE table set datefield = date() where datefield is null

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2

UPDATE table set datefield = date() where datefield is null

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

thanks bob..I have tried
if rs("creation_date") = null then
rs("creation_date") = date()
rs.update

but this didn't work either

I'm going mad...or I'm just plain stupid
Jul 19 '05 #3

"Alistair" <news@*remove*alistairb.co.uk> wrote in message
news:10*************@corp.supernews.com...

UPDATE table set datefield = date() where datefield is null

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

thanks bob..I have tried
if rs("creation_date") = null then
rs("creation_date") = date()
rs.update

but this didn't work either

I'm going mad...or I'm just plain stupid


a query on number of records that contain a null in this field returns 0
a query on the byte length of this field for those that don't contain a date
returns blank

doesn't make sense to me
Jul 19 '05 #4
> if rs("creation_date") = null then

You can't say this in ASP. You would say if isNull(something) then

However, I think you should do this:

sql = "UPDATE table SET Creation_date = Date() WHERE Creation_date IS NULL"

(and other clauses to identify the single row, if necessary)

DON'T use a recordset and a cursor to perform UPDATEs.
http://www.aspaq.com/2191

An important thing to keep in mind is that an empty string is not the same
as NULL. And also, that you can't store an empty string in a date column.
It either has a value, or the value is unknown (NULL).

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #5

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
if rs("creation_date") = null then
You can't say this in ASP. You would say if isNull(something) then

However, I think you should do this:

sql = "UPDATE table SET Creation_date = Date() WHERE Creation_date IS

NULL"
(and other clauses to identify the single row, if necessary)

DON'T use a recordset and a cursor to perform UPDATEs.
http://www.aspaq.com/2191


I'm going phucking mad

set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\dataset213.mdb"

set rs = server.CreateObject ("ADODB.Recordset")
rs.CursorType = 3
rs.locktype = 3
newdate = dateadd("d",-365,date) 'because I need an old date
strsql = "UPDATE usersdata SET Creation_date = " & newdate & " WHERE
Creation_date IS NULL"
rs.open strsql, conn
I get an error message telling me that the operation in line 22 (the strSQL
= line) is not allowed because the object is closed....
of course it's closed!!!..I haven't phucking opened it yet!!..it's just a
string ffs!!!!

if I include the line response.write strSQL I get the correct string (I
think)

UPDATE users SET Creation_date = 10/01/2003 WHERE Creation_date IS NULL

but as soon as I remove these lines...it goes pearshaped..

I know it's a lot to ask..but

can someone please explain how this is going wrong???

I have been having soo much trouble with sql queries

I'm getting very frustrated now, been on this since 6 and it's now nearly
9:30!!

6 million thank yous
Jul 19 '05 #6


--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
DON'T use a recordset and a cursor to perform UPDATEs.
http://www.aspaq.com/2191
I'm going phucking mad


Because you didn't read the article. Grow up and stop swearing like a kid
at recess.
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\dataset213.mdb"
set rs = server.CreateObject ("ADODB.Recordset")
rs.CursorType = 3
rs.locktype = 3
newdate = dateadd("d",-365,date) 'because I need an old date
strsql = "UPDATE usersdata SET Creation_date = " & newdate & " WHERE
Creation_date IS NULL"
rs.open strsql, conn
Once again. Don't use a recordset to affect data. Recordsets are for
*reading* data. Also, you need to delimit your date correctly.

How about this.

set Conn = CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft ... "
newdate = dateadd("d",-365,date)
strsql = "UPDATE usersdata SET Creation_date = #" & _
newdate & "# WHERE Creation_date IS NULL"
conn.execute(sql)
UPDATE users SET Creation_date = 10/01/2003 WHERE Creation_date IS NULL
This will try to set the date to 10 divided by 1 (10), divided by 2003 (some
very small number).
I'm getting very frustrated now, been on this since 6 and it's now nearly
9:30!!


If you read the articles posted to you, and spend time reading tutorials
instead of diving into things you know little about, you might have better
luck, instead of having a big temper tantrum.
Jul 19 '05 #7

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:u0****************@TK2MSFTNGP11.phx.gbl...


--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
DON'T use a recordset and a cursor to perform UPDATEs.
http://www.aspaq.com/2191
I'm going phucking mad


Because you didn't read the article. Grow up and stop swearing like a kid
at recess.
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=c:\dataset213.mdb"

set rs = server.CreateObject ("ADODB.Recordset")
rs.CursorType = 3
rs.locktype = 3
newdate = dateadd("d",-365,date) 'because I need an old date
strsql = "UPDATE usersdata SET Creation_date = " & newdate & " WHERE
Creation_date IS NULL"
rs.open strsql, conn


Once again. Don't use a recordset to affect data. Recordsets are for
*reading* data. Also, you need to delimit your date correctly.

How about this.

set Conn = CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft ... "
newdate = dateadd("d",-365,date)
strsql = "UPDATE usersdata SET Creation_date = #" & _
newdate & "# WHERE Creation_date IS NULL"
conn.execute(sql)
UPDATE users SET Creation_date = 10/01/2003 WHERE Creation_date IS NULL


This will try to set the date to 10 divided by 1 (10), divided by 2003

(some very small number).
I'm getting very frustrated now, been on this since 6 and it's now nearly 9:30!!


If you read the articles posted to you, and spend time reading tutorials
instead of diving into things you know little about, you might have better
luck, instead of having a big temper tantrum.


Aaron,

my sincere apologies.

I was just very frustrated last night after looking at something which
appeared to be right but wasn't and not having the skill to work it out.

thank you for your help and patience

Alistair
Jul 19 '05 #8
> I was just very frustrated last night after looking at something which
appeared to be right but wasn't and not having the skill to work it out.


In the future, please keep that frustration to yourself. It doesn't do
anyone any good here.

People are here to help and be helped, not to put up with grade school
antics.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #9

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

Similar topics

2
by: Mark | last post by:
I am attempting to populate several textbox controls from VBA code. With each attempt, I get the following error: "The macro or function set to the BeforeUpdate or ValidationRule property for...
1
by: John Phelan-Cummings | last post by:
I'm not certain if this made the post. Sorry if it's a repeat: Using a Button to take an autonumber from one form to populate another autonumber field on another form. I have a Mainform "A"...
2
by: Dave McKie | last post by:
Hi all I am trying to Populate a combo box from a selection in an adjacent Listview. The Listview lists as a string the field names of 4 different fields in tblFile. So far I can populate the...
5
by: Richard Rosser | last post by:
Greetings. I know not one word of Javascript and wondered if there was an easy way to pre-populate a form field in a similar manner to populating an eMail 'subject' field? - The following...
11
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and...
1
by: indhu | last post by:
Hi all, I want 2 know, how to populate using 2 combo box to populate other field. right now am using click event of combo to populate the other field but i want to select both combo1 and combo2 ...
4
by: AccessNewbie | last post by:
Hi all, I've been trying to figure out how to populate a field by whether or not the user checked a checkbox (but to no avail). For background, I have a cluster of checkboxes that are 'Quick...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
3
by: Excel 009 | last post by:
Hi, Is there a way to populate sequential numbers in a field using SQL or VBA? If yes, how? Assume the following is my existing table: Fruit ID Apply Banana
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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.