示例#1
0
        public SqlDataReader ExecuteReader(string cmdText, CommandType type, int timeout, params SqlParameter[] parameters)
        {
            SqlCommand command = CreateCommand(cmdText, type, timeout, parameters);

            using (QueryProfiler profiler = new QueryProfiler(cmdText, parameters))
            {
                try
                {
                    return(command.ExecuteReader());
                }
                catch (SqlException e)
                {
                    throw new DatabaseException(QueryProfiler.ReplaceParameters(cmdText, parameters), e);
                }
            }
        }
示例#2
0
        public DataTable ReadDataTable(string cmdText, CommandType type, int timeout, params SqlParameter[] parameters)
        {
            SqlCommand command = CreateCommand(cmdText, type, timeout, parameters);

            using (QueryProfiler profiler = new QueryProfiler(cmdText, parameters))
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                {
                    try
                    {
                        DataTable result = new DataTable();
                        adapter.Fill(result);
                        return(result);
                    }
                    catch (SqlException e)
                    {
                        throw new DatabaseException(QueryProfiler.ReplaceParameters(cmdText, parameters), e);
                    }
                }
            }
        }