Solved

Column name validation

Posted on 2006-07-17
4
1,292 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
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 use and create keystrokes in Netbeans IDE 8.0 for Windows.

771 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

11 Experts available now in Live!

Get 1:1 Help Now