Board index » delphi » field truncated to 255 characters - why?

field truncated to 255 characters - why?

I've written a data conversion routine that feeds data into a SQL
Server 7 database.  So I have code like:

destination.fieldbyName('Summary').asString := getMemoInfo(oldfield);

the getMemoInfo is returning long strings, I've not overridden the
default {$H+} directive to use widestrings and yet the text is
truncated to 255 characters.  The destination field Summary is defined
in SQL7 as 2000 varchar.

Is there something I'm not aware of, should I be using
destination.fieldbyName('Summary').asSomethingElse ?

Please any ideas would be gratefully received.

thanks, Rob
--------------------------------
email: Rob.Da...@unn.ac.uk
Web:   http://www.unn.ac.uk/~isu8

 

Re:field truncated to 255 characters - why?


Quote
On Wed, 23 Jun 1999 19:30:15 GMT, Rob.Da...@unn.ac.uk (Rob Davis) wrote:
>I've written a data conversion routine that feeds data into a SQL
>Server 7 database.  So I have code like:

>destination.fieldbyName('Summary').asString := getMemoInfo(oldfield);

>the getMemoInfo is returning long strings, I've not overridden the
>default {$H+} directive to use widestrings and yet the text is
>truncated to 255 characters.  The destination field Summary is defined
>in SQL7 as 2000 varchar.

>Is there something I'm not aware of, should I be using
>destination.fieldbyName('Summary').asSomethingElse ?

The TField.AsString property was designed primarily for use with string
columns (CHAR in SQL parlance), which did not exceed 254 characters. In
your case, I would suggest using either the TField.Value or
TField.AsVariant properties for the data assignment.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski     "An inventor is a person who makes an ingenious
Felton, CA         arrangement of wheels, levers and springs, and believes
                   it civilization."          -- Ernest Dimnet (1866-1954)

Re:field truncated to 255 characters - why?


Steve,

no the .Value doesn't work either.  I too first thought it might be to
with the .asString or the driver but if I write to a field of type
Text I can happily write more than 255 characters.  

This puzzled me so, within SQL7 Enterprise Manager, I tried inserting
a record to a table with a varchar field of length 2000.  This gave no
problem.  So, I thought the problem must be with the way my Delphi
program writes to a varchar field.  So then I created a program that
wrote to a Text field and it worked fine.  Then, and this is the
twist, I tried, within SQL7, inserting into a varchar field using a
select from the text field and once again the varchar field truncated
to 255.

So it would seem to be a bug in SQL7.

regards, Rob

Quote
koter...@NOSPAMgte.net (Steve Koterski) wrote:
>On Wed, 23 Jun 1999 19:30:15 GMT, Rob.Da...@unn.ac.uk (Rob Davis) wrote:

>>I've written a data conversion routine that feeds data into a SQL
>>Server 7 database.  So I have code like:

>>destination.fieldbyName('Summary').asString := getMemoInfo(oldfield);

>>the getMemoInfo is returning long strings, I've not overridden the
>>default {$H+} directive to use widestrings and yet the text is
>>truncated to 255 characters.  The destination field Summary is defined
>>in SQL7 as 2000 varchar.

>>Is there something I'm not aware of, should I be using
>>destination.fieldbyName('Summary').asSomethingElse ?

>The TField.AsString property was designed primarily for use with string
>columns (CHAR in SQL parlance), which did not exceed 254 characters. In
>your case, I would suggest using either the TField.Value or
>TField.AsVariant properties for the data assignment.

>_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
>Steve Koterski     "An inventor is a person who makes an ingenious
>Felton, CA         arrangement of wheels, levers and springs, and believes
>                   it civilization."          -- Ernest Dimnet (1866-1954)

--------------------------------
email: Rob.Da...@unn.ac.uk
Web:   http://www.unn.ac.uk/~isu8

Other Threads