/// <summary> /// Advances the <see cref="T:System.Data.IDataReader"/> to the next record. /// </summary> /// <returns> /// true if there are more rows; otherwise, false. /// </returns> public bool Read() { if (MapiLib.MapiFetchRow(_queryHandle) > 0) { DieQueryError(); return(true); } return(false); }
/// <summary> /// Executes the query, and returns the first column of the first row in the resultset returned by the query. Extra /// columns or rows are ignored. /// </summary> /// <returns> /// The first column of the first row in the resultset. /// </returns> public object ExecuteScalar() { var connHandle = _connection.GetConnectionHandle(); var queryHandle = MapiFactory.GetQueryHandle(connHandle, CommandText); object result = null; if (MapiLib.MapiFetchRow(queryHandle) > 0) { MapiFactory.DieQueryError(connHandle, queryHandle); result = MapiLib.MapiFetchField(queryHandle, 0); MapiFactory.DieQueryError(connHandle, queryHandle); } MapiFactory.CloseQueryHandle(queryHandle); return(result); }