ADO.NET DataColumn enumeration

Posted on 2004-10-08
Medium Priority
Last Modified: 2008-03-17
Dear all,

Let us assume that one of my MySQL tables has an enum column, defined as follows:

status ENUM( 'open', 'accepted', 'rejected' ) NOT NULL

I would like to define a DataColumn in my DataTable that matches this type. Unfortunately, a DataColumn cannot be of type ‘enumeration’. How am I going about this? How can I match this MySQL data type?

Many thanks in advance.

Best wishes,

Question by:csetzkorn
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 12259831
VarChar (8)?


Author Comment

ID: 12260089

Sure, but I would like to make it more strongly typed, to enforce that the value can only be 'open', 'accepted', 'rejected'.

BTW could someone recomend a good book, tutorial etc. on ADO.NET? I am a bit confused that I have to replicate the whole structure of the database structure in the DataSet object in order to update etc. I know that this has advantages, because the DataSet object can exist independently from the database.

LVL 96

Accepted Solution

Bob Learned earned 252 total points
ID: 12260129
You will not be able to do this with a typed DataColumn.  Your code will have to handle that validation.

Essential ADO.NET


Assisted Solution

Farshid-Zaker earned 248 total points
ID: 12261313
the better way is adding a column dynamically to your dataset of type int or byte. Have a mapping between your enumeration values and numbers 1, 2 and 3. Then add a constraint on that column, indicating it's range should be between 1 and 3.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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.

Join & Write a Comment

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.

597 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