Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine type of column
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Determine type of column
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01574150
Message ID:
01574150
Views:
73
Hi,
UPDATE: Found Solution!  Will CAST the BIT column into INT as CAST( BitColumn AS INT ) as IntColumn
Is there a way to determine in code the type of value in a column of a data set? Here is example:
DataTable myTable = myDataSet.Tables[0];

DataRow dr = myTable.Rows[0];

// Row dr has a column ACCESS_ENABLED.  I need to know if the type is Int or Bit (True/False)
What happened is that sometimes this column is integer and I check if the value 1 using the following method:
lUserHasAccess = dr["ACCESS_ENABLED"].ToString().Equals("1");
But if the value of the column is True (type in SQL Server is BIT) it always returns False. So I need to change the code to evaluate the type.

TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View

Click here to load this message in the networking platform