Link to home
Start Free TrialLog in
Avatar of mkmko
mkmkoFlag for Germany

asked on

Delphi 7 LDAP via ADO / Field type

Hi all,
this is a question for legacy Delphi - I have to use D7 for this small project. I need to use some values from LDAP records, so I'm using a SQL query in a 'TBetterADODataSet' to retrieve my data. Later on, I want to display it in a grid and use some of those data in a report. But I don't have a plan how to use fields being obviously strings, but are inserted as TVariantField. This is the case for 'description', which holds the additional text information for a person in our AD.
When I'm adding that field to my SQL command and trying to insert it into my field list, it always inserts as 'TVariantField'. My grid can't use that field type.

Any ideas or workarounds? Sorry - I'm no longer doing my daily D7 programming for some years now, so there's some lack in experience :(

TIA
Michael
Avatar of jimyX
jimyX

If it contains String then Typecasting to string should do.

I suspect you can deal with similarly to when trying to show Memo fields in a DBGrid.

Can you test if "ShowMessage(urDataSet.FieldByName('description').AsString);", in a Button Click, gets you the data?
Avatar of mkmko

ASKER

Sorry for the delay... no, unfortunately this doesn't work. I have to translate the exception message because of my german Delphi installation: 'Error variant of type (array variant) couldn't be converted into type (string)'.

I checked that the ShowMessage is used and placed correctly by testing FieldByName('anotherStringField').AsString. This  will work.

Michael
ASKER CERTIFIED SOLUTION
Avatar of jimyX
jimyX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mkmko

ASKER

Yes, this works! Great!
Thanks a lot.

Michael