[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

ADO Display label in DB grid

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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 …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 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