Re: ActualSize returns -1 for Text fields
- From: "Mark J. McGinty" <mmcginty@xxxxxxxxxxxxxxx>
- Date: Sun, 25 Sep 2005 03:21:27 -0700
"Rod da Silva" <RodDaSilva@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23M4VNcEwFHA.1168@xxxxxxxxxxxxxxxxxxxxxxx
> Hi all,
>
> I have a table called 'mytable' with two fields in it Fld1, and Fld2.
> Fld1
> is a text field and Fld2 is char(10) . If I create an ADORecordSet object
> using the following query:
>
> select * from mytable
>
> I can't read the contents of the text field (Fld1). ActualSize of this
> field is always -1 even though I can see the data in the table from SQL
> Enterprise Manager. Same is true if I use the query explicitly listing
> the
> fields:
>
> select Fld1, Fld2 from mytable
>
> ** However *** if I query for:
>
> select Fld2, Fld1 from mytable
>
> it works (notice the field order is different)!! I can access the
> contents
> of the Fld1 text field using this query.
>
> So I do some digging on the internet and find out that this is a farily
> well
> known issue. Text fields must be the last field in the field list of a
> select statement to be returned properly. This is why the above workaround
> (placing FLD1 last in the field list) works.
>
> But while this workaround works in this trivial case, my real problem is
> that I have tables with multiple text fields so there appears no single
> query that will return all my text data.
>
> My question is ... is there a hotfix for this?? I am running MDAC 2.8 RTM
> under Windows 2000 against SQL Server Developer Edition ver (8.00 763
> (SP3)).
>
> I really need a fix for this since using varchar instead of text fields
> isn't an option for me (I need CLOBs). Any help would be greatly
> appreciated.
Technically, you're supposed to use either field.GetChunk(), or streams to
handle text/ntext/image columns. It only works as you describe if the total
size of the row, including the text, is under 8060 bytes anyway.
Personally I prefer streams:
Dim s
s = CreateObject("ADODB.Stream")
s.Mode = adModeReadWrite ' 3
s.CharSet = "iso-8859-1"
s.Open
[...]
' read data from text field
s.WriteText rs.Fields("MyTextCol1").Value
' copy data to string buffer
s.Position = 0
Dim stringbuf
stringbuf = s.ReadText()
-Mark
> Rod
>
>
>
.
- Follow-Ups:
- Re: ActualSize returns -1 for Text fields
- From: Rod da Silva
- Re: ActualSize returns -1 for Text fields
- References:
- ActualSize returns -1 for Text fields
- From: Rod da Silva
- ActualSize returns -1 for Text fields
- Prev by Date: Re: Getting the correct date format from SQL-Server 2000
- Next by Date: Re: ActualSize returns -1 for Text fields
- Previous by thread: ActualSize returns -1 for Text fields
- Next by thread: Re: ActualSize returns -1 for Text fields
- Index(es):
Relevant Pages
|
|