I have a field in an SQL DB that is defined as CHAR(100)...I am using the SDAC components (still on trial)...and I am performing the following:
TempStr := datamodule.tablename.fieldbyname('fieldname').asstring;
As I said this field is defined as CHAR(100)...however, its only returning data up to the first NULL it finds in the field...not the entire 100 bytes. How do I get this to function to return all 100 bytes of the field and not stop at the first NULL value in the field that it runs into?
I know...this is not good database management...however, this DB came from an old COBOL system where they did a lot of large fields with several sub-fields in them so they didn't have to keep expanding the DB.
In COBOL this is pretty easy to diffine in a buffer...but I'm struggling with accessing all 100 bytes of data in Delphi 6.
Any recomomendation?
Thanks,
Jim
FieldByName('fieldname').AsString not Returning entire field
FieldByName('fieldname').AsString not Returning entire field
I don't have any control over the database definition...I'm stuck with the CHAR(100)...can I define a binary field (target) in Delphi and manipulate the data there? If so, how would I define a 100 byte binary data field?
Thanks in advance!
Jim
Thanks in advance!
Jim
You can change the field type with ALTER TABLE ... ALTER COLUMN statement.
In other way you can change your SELECT query using CAST statement for change of field type, like this:
In other way you can change your SELECT query using CAST statement for change of field type, like this:
Code: Select all
SELECT CAST(FieldName AS BINARY(100)) FieldAlias, ...