Nepethya Rana

Nepethya Rana

  • 1.5k
  • 335
  • 66.7k

how do i cast object from data reader to boolean value ?

Sep 15 2017 1:38 PM
how do i cast object from data reader to boolean value ?
Employee has IsActive property which is Bool data type. 
 
I tried followings but got exception .
 
emp.IsActive = (bool)rdr["Is_Active"];
emp.IsActive = Convert.ToBoolean(rdr["Is_Active"]);
var i = rdr.GetOrdinal("Is_Active");
emp.IsActive = rdr.GetBoolean(i);

Answers (1)