Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Losing Date Column in ASP

0 views
Skip to first unread message

Ken

unread,
Apr 6, 2004, 7:20:36 PM4/6/04
to
We have run into a situation where simply accessing one particular
value from an ADO recordset is destroying another value. Here is a
code snippet:
Dim rs, ext, ged
rs = dbConnection.Execute("select * from tblDemo where PIN = '9'")
ext = rs("Extension")
ged = rs("GraceEndDate")
Response.Write("ext: " & ext & ". ged: " & ged)

In this example, ged will be Empty, even though the column in the
table contains a valid date.

By accessing the GraceEndDate first, both values will be displayed
properly:
Dim rs, ext, ged
rs = dbConnection.Execute("select * from tblDemo where PIN = '9'")
ged = rs("GraceEndDate")
ext : ext = rs("Extension")
ged : ged = rs("GraceEndDate")
Response.Write("ext: " & ext & ". ged: " & ged)

Or, if we specify all the column names in the select statement, the
value will not be lost:
Dim rs, ext, ged
rs = dbConnection.Execute("select Extension, GraceEndDate from
tblDemo where PIN = '9'")
ext : ext = rs("Extension")
ged : ged = rs("GraceEndDate")
Response.Write("ext: " & ext & ". ged: " & ged)

The database we're accessing is SQL Server 2000. We're programming in
Classic ASP, with an IIS 5.0 server.

Does anyone know why the column is being trashed?
Does anyone have a better workaround than the ones here (accessing the
date before it gets lost, or specifying all the columns instead of
using *)?

Thanks in advance.
-Ken

John Boatner, MCSD, MCDBA, MCSE, MCSA, MCDST

unread,
Apr 6, 2004, 11:20:18 PM4/6/04
to
Hi Ken,

You wouldn't happen to have an 'On Error Resume Next' line somewhere in the
ASP code would you? - Just a curiosity thing - I'm wondering if there are
any errors that may be occurring when you try to access the Extension field
first.

What are the datatypes of the fields you mentioned? Does it matter if you
access data from any other fields?

I agree that this is odd, but it is strangely familiar.

Regards,

John Boatner
MCSD, MCDBA, MCSE, MCSA, MCDST
J2 Technologies, Inc.
http://www.j2tech.com


"Ken" <kenneth...@nelnet.net> wrote in message
news:1d0f453b.04040...@posting.google.com...

Ken

unread,
Apr 7, 2004, 4:10:37 PM4/7/04
to
John, Thanks for your reply. I went back and stripped out all
unnecessary code, and now there are no On Error Resume Next stmts, but
the behavior hasn't changed. I tested Err.number previously while
tracking down this issue, and I am pretty confident that no error is
being set.

After looking into it further, if I access any column "to the right
of", or "after" GraceEndDate before accessing GraceEndDate, the
GraceEndDate is lost. So it is not the Extension column per se that is
causing the problem.

The data type of GraceEndDate is datetime. Extension is a varchar.
Some of the other columns that trash the date are bit and char.

I've tried this with several rows from the table, and they all produce
the same same symtpoms. I.e., its not a particular value of the
Extension or Grace End Date that matters.


"John Boatner, MCSD, MCDBA, MCSE, MCSA, MCDST" <john.boatner@-nospam-
j2tech.com> wrote in message news:<kmKcc.3813$ZJ6....@bignews5.bellsouth.net>...

John Boatner, MCSD, MCDBA, MCSE, MCSA, MCDST

unread,
Apr 8, 2004, 3:06:19 PM4/8/04
to
Is GraceEndDate a calculated field?

--

Regards,

John Boatner
MCSD, MCDBA, MCSE, MCSA, MCDST
J2 Technologies, Inc.
http://www.j2tech.com

"Ken" <kenneth...@nelnet.net> wrote in message
news:1d0f453b.04040...@posting.google.com...

0 new messages