Populate a combo with user-friendly names instead of field names

  • Thread starter Thread starter Earl
  • Start date Start date
E

Earl

I want to populate a combo with the field names from several tables -- but
I'd like to do it "nicely" without putting them in there static. I then want
to use the combo selections from this combo to pull the actual values out of
the fields, i.e., select the filter, then select a filter criteria.

No problem with doing any of the above -- except I do not know if or how I
can put in more user-friendly aliases into the first combo, i.e., "Secondary
interest" where the field name is "SecondInterest". I'm thinking perhaps a
stored procedure and then alias the names in the sproc (altho that is still
a bit of a "hard-code")? Anyone with a better idea?
 
¤ I want to populate a combo with the field names from several tables -- but
¤ I'd like to do it "nicely" without putting them in there static. I then want
¤ to use the combo selections from this combo to pull the actual values out of
¤ the fields, i.e., select the filter, then select a filter criteria.
¤
¤ No problem with doing any of the above -- except I do not know if or how I
¤ can put in more user-friendly aliases into the first combo, i.e., "Secondary
¤ interest" where the field name is "SecondInterest". I'm thinking perhaps a
¤ stored procedure and then alias the names in the sproc (altho that is still
¤ a bit of a "hard-code")? Anyone with a better idea?
¤

Some databases support a Description property for a Column in a database. You could probably use
that and extract it from the schema.

What kind of database you are using?


Paul
~~~~
Microsoft MVP (Visual Basic)
 
YOu can use a TypedDataSet and use the ColumnMappings to accomplish this.
SO the DB Name is SecondINterest but the DataColumn name could be Second
Interest and you'd use the Mapping to handle this.
 
Thanks, that's a good thought Paul. It's SQL Server but I had not considered
using the Description property! Too many late nights ...
 
Thanks for the thought Cor. But I was trying to avoid a hard mapping, so at
this point, I'm going to use the Description attribute mentioned by Paul
below. Nice informative website!
 
Thanks for the idea Bill. I will store that one away for future use, but the
Description attribute idea is more appealing to me for this project.
 
Earl,

Probably I misunderstood this sentence from you.
I want to populate a combo with the field names from several tables -- but
I'd like to do it "nicely" without putting them in there static.

Cor
 
¤ Thanks, that's a good thought Paul. It's SQL Server but I had not considered
¤ using the Description property! Too many late nights ...
¤

With SQL Server you can use a built-in function to retrieve the Description values:

Using the Customers table in the Northwind database:

All columns:
SELECT * FROM ::fn_listextendedproperty ('Ms_description', 'User','dbo', 'table', 'Customers',
'column', default)

Specific column:
SELECT * FROM ::fn_listextendedproperty ('Ms_description', 'User','dbo', 'table', 'Customers',
'column', 'CustomerID')

I don't think the Description property shows up in the schema if using the GetOleDbSchemaTable
method.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Cor,

Hehe. No doubt, and no harm. Most of the time in the past I have totally NOT
understood much of what you've written. Your English has improved markedly
in the past year.
 
Back
Top