public static DateTime GetDateTimeFromRdr(MySql.Data.MySqlClient.MySqlDataReader rdr, string column) { try { int ord = rdr.GetOrdinal(column); //if (rdr[ord] == DBNull.Value) return DateTime.MinValue; string typeName = rdr.GetDataTypeName(ord); if (typeName == "DATE") { rdr.GetMySqlDateTime(ord).GetDateTime(); } return((DateTime)rdr[column]); } catch (Exception exc) { log.Error("GetDateTimeFromRdr", exc); return(DateTime.Now); } }
public static int GetIntFromRdr(MySql.Data.MySqlClient.MySqlDataReader rdr, string column) { try { int ord = rdr.GetOrdinal(column); if (rdr[ord] == DBNull.Value) { return(0); } string typeName = rdr.GetDataTypeName(ord); if (typeName == "TINYINT") { return(rdr.GetInt16(ord)); } return(rdr.GetInt32(ord)); } catch (Exception exc) { log.Error("GetIntFromRdr", exc); return(0); } }