예제 #1
0
        protected internal int ExecuteNonQuery(string sqlQuery, CSParameterCollection parameters)
        {
            long logId = Log(sqlQuery, parameters);


            try
            {
                using (ICSDbCommand dbCommand = CreateCommandInternal(sqlQuery, parameters))
                    dbCommand.ExecuteNonQuery();

                return(1);
            }
            catch (InvalidOperationException)
            {
                return(-1);
            }
            catch (Exception ex)
            {
                throw new CSSQLException("ExecuteNonQuery exception", ex, sqlQuery, parameters);
            }
            finally
            {
                LogEnd(logId);

                CSNameGenerator.Reset();
            }
        }
예제 #2
0
        internal object GetScalar(string sqlQuery, CSParameterCollection parameters)
        {
            long logId = Log(sqlQuery, parameters);

            try
            {
                using (ICSDbCommand dbCommand = CreateCommandInternal(sqlQuery, parameters))
                {
                    using (ICSDbReader reader = dbCommand.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            object r = reader[0];

                            return((r is DBNull) ? null : r);
                        }
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw new CSSQLException("GetScalar exception", ex, sqlQuery, parameters);
            }
            finally
            {
                LogEnd(logId);

                CSNameGenerator.Reset();
            }
        }
예제 #3
0
        protected internal ICSDbReader CreateReader(string sqlQuery, CSParameterCollection parameters)
        {
            long logId = Log(sqlQuery, parameters);

            try
            {
                using (ICSDbCommand dbCommand = CreateCommandInternal(sqlQuery, parameters))
                    return(dbCommand.ExecuteReader());
            }
            catch (Exception ex)
            {
                throw new CSSQLException("Error executing query. Possible syntax error", ex, sqlQuery, parameters);
            }
            finally
            {
                LogEnd(logId);

                CSNameGenerator.Reset();
            }
        }