How to add columns to TOraLoader at runtime

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

How to add columns to TOraLoader at runtime

Post by jjeffman » Mon 20 Nov 2017 18:02

Hello,

I am using ODAC v 9.7.26 on C++Builder 6.0 and I would like to add columns to a TOraLoader component at runtime.

I could not find any sample in the Help file, and the C++Builder demo is a little bit poor.

I was not able to find out how to add a TDAColumn to the Columns property of TOraLoader.

How can I do that? I am able to deal with Delphi code.

Thank you very much.

Best regards,

Jayme Jeffman Filho

jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Re: How to add columns to TOraLoader at runtime

Post by jjeffman » Mon 20 Nov 2017 20:09

Never mind. I have got it to work using the same process used to add columns to a TDBGrid.

Best regards,

Jayme Jeffman Filho

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: How to add columns to TOraLoader at runtime

Post by MaximG » Wed 22 Nov 2017 13:12

You can add columns to TOraLoader at runtime as follows. For example, for an integer field "ID" :

Code: Select all

  ...
  TDAColumn* NewColumn;

  NewColumn = (TDAColumn*)OraLoader -> Columns -> Add();
  NewColumn -> Name = "ID";
  NewColumn -> FieldType = ftInteger;
  ...

jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Re: How to add columns to TOraLoader at runtime

Post by jjeffman » Wed 22 Nov 2017 15:51

Hello Maxim,

Thank you very much for answerung me.

I did as you suggested, but as the application is connected to the database, and I need to fill up all tables fields, I am using the TOraLoader::CreateColumns() method every time I change the TOraLoader::TableName property, that did the trick.

Thank you very much.

Best regards,

Jayme Jeffman Filho

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: How to add columns to TOraLoader at runtime

Post by MaximG » Thu 23 Nov 2017 12:12

You are absolutely right. The CreateColumns method creates all the fields of the table specified in the TableName property : https://www.devart.com/odac/docs/?devar ... umns().htm

Post Reply