Re: ActualSize returns -1 for Text fields
- From: "Daniel Crichton" <msnews@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Sep 2005 08:49:19 +0100
Rod wrote on Tue, 27 Sep 2005 00:46:54 -0400:
> Has anyone out there have a table with more then one Text field? Seems to
> me this problem would affect anyone with such a table that needed to run a
> query that returned two or more of these fields.
I have many tables with multiple text fields, and don't seem to have any
problems no matter what order I return them in, so long as I read from left
to right.
>> IIRC, using a server side cursor the
>> first time you read the field ADO will then discard the underlying
>> pointer to that text field, and all fields to the left of it in the
>> recordset.
> Then
>> if you attempt to read the field or it's properties a second time it will
>> appear as empty with a size of -1. I always read ADO recordsets from left
> to
>> write, and if I need to check the value of a field more than once then I
>> read it into a variable, and use the variable for subsequent tests.
>
> What exactly do you mean by "I always read ADO recordsets from left to
> right"?
Say you have:
col1 - integer
col2 - text
select col1, col2 from table
Reading from "left to right" is ensuring that you read the value of col1
before col2. If col2 is a text field, and you read it first, ADO in certain
circumstances will discard the value in col1. eg.
adoRec.Open "select col1, col2 from table"
vMyVal2 = adoRec("col2")
vMyVal1 = adoRec("col1")
vMyVal1 will contain a null, rather than the actual value that was in col1.
This can also cause problems:
adoRec.Open "select col1, col2 from table"
vMyVal1 = adoRec("col1")
If Not IsNull(adoRec("col2")) Then
vMyVal2 = adoRec("col2")
End If
The IsNull returns false as col2 is not null, but ADO discards the
underlying data, IIRC it's an efficiency tweak so that memory footprints of
recordsets are kept as small as possible. The subsequent assignment of the
value of col2 to vMyVal2 results in a null being stored in the variable
because the IsNull call has already read the data.
Dan
.
- Follow-Ups:
- References:
- ActualSize returns -1 for Text fields
- From: Rod da Silva
- Re: ActualSize returns -1 for Text fields
- From: Daniel Crichton
- Re: ActualSize returns -1 for Text fields
- From: Rod da Silva
- ActualSize returns -1 for Text fields
- Prev by Date: Re: ActualSize returns -1 for Text fields
- Next by Date: Re: ADO vs. Progress Bar
- Previous by thread: Re: ActualSize returns -1 for Text fields
- Next by thread: Re: ActualSize returns -1 for Text fields
- Index(es):
Relevant Pages
|
|