This is a snippet from some code that loops through all the columns in a datatable and checks the data type.
if (Table.Columns[i].DataType == typeof(System.String))
{
}
>Hi,
>
>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
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.