Solved

ADO Display label in DB grid

Posted on 2004-04-12
5
261 Views
Last Modified: 2010-04-05
HI I would like to know how do you change the display label of a field in the grid if your TADOQuery SQL are both declared in the codes instead of using components.
looking at the example below, the genre will display as GENRE, product_type will be display as PRODUCT_TYPE in my grid. How do you change it? do i have to declare the stringfields or tfields? I don't know how to do it. Please help.THANKS!

procedure  TFrameProductBook.BitBtnCategoryLookUPClick(Sender: TObject);
var SQL :string;

begin
 SQL := 'select genre, category_id from category, product_type';
 SQL := SQL + ' where product_type = ''B''';
  SQL := SQL + ' order by :order';
  with FormCategoryLU do
  begin
  QryLU.SQL.text := SQL;

  QryLU.Open;
.
,
,
0
Comment
Question by:AgeOfWars
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 10811782
   for i := 0 to DBGrid1.Columns.Count - 1 do
      begin
      if DBGrid1.Columns[i].FieldName = 'genre' then
        DBGrid1.Columns[i].Title.Caption := 'Caption genre;
      .....
      end;
0
 
LVL 17

Expert Comment

by:mokule
ID: 10812910
You can also rewrite

 SQL := 'select genre as caption, category_id from category, product_type';

Choose what is more convenient in a given circumstances.
0
 

Author Comment

by:AgeOfWars
ID: 10812997
Hi mkule,
Thanks for you reply. the first one didn't work for me :(
I know that you can manupulate the sql statement, but i wanna find out how to play with the field settings. the Tstringfileds and the Tfields in the columns of the Query because I would wanna make some of them invisible.

do you know any other way? Thanks

Ian
0
 

Author Comment

by:AgeOfWars
ID: 10813034
Hi Mokule,

I have this error.

SQL := 'select genre, category_id from category, product_type';
 SQL := SQL + ' where product_type = ''B''';
  SQL := SQL + ' order by :order';

I can write 'select genre as CAPTION but it would appear as CAPS.
If I tried 'select genre as ''Genre'' from category' it will return error.

Please help.
Thank you
ian

0
 
LVL 17

Accepted Solution

by:
mokule earned 125 total points
ID: 10813145
It should work.
One apostrophe was missed
What do you mean be don't work.

for i := 0 to DBGrid1.Columns.Count - 1 do
      begin
->>  if DBGrid1.Columns[i].FieldName = 'genre' then
          DBGrid1.Columns[i].Title.Caption := 'Caption genre';
      end;

stop program on this instruction in the loop and look what are Your Filed names
If they are CAPS rewrite as

  if DBGrid1.Columns[i].FieldName = 'GENRE' then
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question