MySql.Data.MySqlClient.MySqlDataReader.IsDBNull C# (CSharp) Method

IsDBNull() public method

Gets a value indicating whether the column contains non-existent or missing values.
public IsDBNull ( int i ) : bool
i int
return bool
    public override bool IsDBNull(int i)
    {
      return DBNull.Value == GetValue(i);
    }

Usage Example

        //private MySql.Data.MySqlClient.MySqlConnection conn;

        /*public DepartmentPersistence()
         * {
         *  string feashConn;
         *  feashConn = "server=localhost;port=3306;database=fea_starhub;username=root;password=135246;";
         *  try
         *  {
         *      conn = new MySql.Data.MySqlClient.MySqlConnection();
         *      conn.ConnectionString = feashConn;
         *      conn.Open();
         *  }
         *  catch (MySql.Data.MySqlClient.MySqlException ex)
         *  { throw ex; }
         * }*/

        public ArrayList allDepts()
        {
            MySql.Data.MySqlClient.MySqlConnection conn;
            string feashConn;

            feashConn = ConfigurationManager.ConnectionStrings["localDB"].ConnectionString;
            conn      = new MySql.Data.MySqlClient.MySqlConnection();
            try
            {
                conn.ConnectionString = feashConn;
                conn.Open();
                ArrayList d = new ArrayList();
                MySql.Data.MySqlClient.MySqlDataReader getReader = null;
                string getString = "SELECT * FROM Dept_ProgramID;";
                MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn);
                getReader = cmd.ExecuteReader();
                while (getReader.Read())
                {
                    getSingleDept adept = new getSingleDept();
                    adept.DName = getReader.IsDBNull(0) == false?getReader.GetString(0) : null;

                    adept.DEntity = getReader.IsDBNull(1) == false?getReader.GetString(1) : null;

                    adept.ProgramID = getReader.IsDBNull(2) == false?getReader.GetString(2) : null;

                    d.Add(adept);
                }
                return(d);
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            { throw ex; }
            finally { conn.Close(); }
        }
All Usage Examples Of MySql.Data.MySqlClient.MySqlDataReader::IsDBNull