Solved

Column name validation

Posted on 2006-07-17
4
1,300 Views
Last Modified: 2013-12-26
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.
0
Comment
Question by:venkat4sv
[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
  • 2
4 Comments
 
LVL 5

Expert Comment

by:michaelstoffel
ID: 17125691
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.

Mike
0
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 125 total points
ID: 17128694
Hi,

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")
     Messagebox('Information',ls_text)
Next

Regards,
Sandeep
0
 

Author Comment

by:venkat4sv
ID: 17133012
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.
Thanks
Venkat.
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 17136100
Hi,

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.

Regards,
Sandeep
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

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