Typed Dataset and Enum States

I have a simple database that has a customers table.  One of the fields is for the state in which the customer resides.  I was wondering if I put a states table in, with all the state names and abbreviations, if there was a way to create code so that I could do the following:

dim myCustomerTable as new CustomersTable
myCustomer.Item(0).State = States.Florida.FullName

Or simply

myCusomer.Item(0).State = States.Florida

I can see this being possible strictly in code using some sort of enum field, but I would like the possible values to come from the table in the database not from code.

It seems like this would be a very convenient thing to have happen, but I have not been able to find a way to do this myself.

Sterling
LVL 7
SterlingMcClungAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

xersoftCommented:
I think what you are talking about is a dynamic enumeration. I’m not sure if this is possible with the current version of the .net framework.


One thing you might try though, create a small app that writes code for you. This app could be as simple as a form with a multi line textbox and a button on it. When you click the button the program will goto the table you choose, pull data from it and create the code necessary to have an enum of this type.

Next you can copy that code from the textbox into your program.

This idea is not ideal because obviously when you change the database the enum does not change too.

Also keep in mind that enums are kind of like constants. After the program compiles they don’t change unless you make a change in the code and recompile.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

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.