• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1310
  • Last Modified:

Column name validation

How do I get the column name, if I know the database name in Powerbuilder.  Below example shows the

Employee ID                   :         ______emp_id________
(col name : emp_id_t)                 (db name: emp_id)

If I give the col name then I'm getting the result,  but dynamically how do I get the col name.

ls_coltext = "emp_id_t"
ls_coltext = dw_1.Describe(ls_coltext + ".Text")   =====> Employee ID

Here the problem is how do we get the ls_coltext in dynamically and I need final result is: Employee ID
Thanks for your advance help.
  • 2
1 Solution
I'd say you're going about it the wrong way.  The UI should know less about the backend, not the reverse.  Also, there is not necessarily any direct correspondence between a label and a database field, or even a database field and a control painted on the window.  For example:

db column "columnA" has an edit control, but no label
db column "columnA" has 2 controls, a dddw and a non-editable display
db column "columnA isn't painted at all
db column "columnA" is datawindow column "my_column"

That being said, as long as a strict naming convention is followed, you can get all the attributes you need using Describe and loop through the controls on the datawindow looking for what you want (db column emp_id has a label with a name emp_id_t)  If those naming conventions aren't followed, you are out of luck.


when you create any datawindow PB autimatically created labels for each column and name of that label will be colname_t (i.e if column name is emp_id then label name will be emp_id_t).

Now if you have not changed these names, you can do following way...

Case 1 : You need when you click particular column or on focus or want to display some error message for that column.....

string ls_colname,ls_text

ls_colname = dw_1.GetColumnName()     // GetColumnName() obtains the name of the column that has the focus
ls_colname = ls_colname + '_t'  // setting for label
ls_text = dw_1.Describe(ls_coltext + ".Text")
Messagebox('Information','Please input value for ' + ls_text)

Case 2 : if you want for all columns in datawindow...

long ll_count

For ll_count = 1 To Long(dw_1.Object.datawindow.column.count)
     ls_colname = dw_1.Describe("#"+ll_count+".dbname")
     ls_colname = ls_colname + '_t'  // setting for label
     ls_text = dw_1.Describe(ls_coltext + ".Text")

venkat4svAuthor Commented:
Hi Sandeep,
I agreee with PB autimatically created labels for each column and name of that label will be colname_t. But in my datawindow there are different labels(some are without _t and some are different from db name).  Is there any possible way to get label name if we have db name. I appreciate your help.

There is no direct association between label and column in PB. Either you have to rename the labels accordingly ( in specific pattern) OR create a table which contains datawindow + column + label and later you can select from table.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now