/// <summary> /// Executes the command text against the connection. /// </summary> /// <param name="behavior"> An instance of <see cref="T:System.Data.CommandBehavior" /> . </param> /// <returns> A <see cref="T:System.Data.Common.DbDataReader" /> . </returns> protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { //WORKAROUND for Exception: DataReader is already open //if (this.dataReader != null) // ResetDataReader(); if (dataReader != null) { //throw new CUBRIDException(Utils.GetStr(MsgId.DataReaderIsAlreadyOpen)); dataReader.Close(); } BindParameters(); ExecuteInternal(); return(dataReader); }
/// <summary> /// Executes the query and returns the first column of the first row in the result set returned by the query. All other columns and rows are ignored. /// </summary> /// <returns> The first column of the first row in the result set. </returns> public override object ExecuteScalar() { object ret = null; BindParameters(); using (CUBRIDDataReader dr = ExecuteInternal()) { if (dr.Read()) { ret = dr.GetValue(0); } if (ret == null) { if (dr.GetColumnCount() != 0) { ret = DBNull.Value; } } dr.Close(); } return(ret); }