?
Solved

ADO Display label in DB grid

Posted on 2004-04-12
5
Medium Priority
?
263 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 375 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 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