Solved

Column name validation

Posted on 2006-07-17
4
1,293 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tomcat6 in eclipse 2 39
WordPress Editor tool bar I have doesn't match what is in product documentation. 14 67
IronPython and Visual Studio 2013+ 2 92
C#  WebForms or MVC 4 105
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. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now