Typed Dataset and Enum States

Posted on 2006-04-04
Last Modified: 2008-02-01
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.

Question by:SterlingMcClung
    1 Comment
    LVL 5

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    794 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

    16 Experts available now in Live!

    Get 1:1 Help Now