Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ADO.NET DataColumn enumeration

Posted on 2004-10-08
7
Medium Priority
?
974 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
  • 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 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
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 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.

Farshid.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

972 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