Nepethya Rana

Nepethya Rana

  • NA
  • 335
  • 152.1k

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)