Solved

ADO.NET DataColumn enumeration

Posted on 2004-10-08
7
965 Views
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,

Christian
0
Comment
Question by:csetzkorn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 96

Expert Comment

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

Bob
0
 

Author Comment

by:csetzkorn
ID: 12260089
VarChar(8)

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.

Christian
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 63 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
http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=YG5kAlBAaK&isbn=0201758660&itm=4

Bob
0
 
LVL 4

Assisted Solution

by:Farshid-Zaker
Farshid-Zaker earned 62 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.

Farshid.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

622 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