Пример #1
0
        public int ExecuteNonQuery(QueryParameter queryParam)
        {
            this.Open();
            SqlCommand command = new SqlCommand(queryParam.commandText);
            command.Connection = _connection;
            command.Parameters.AddRange(queryParam.parameters.ToArray());
            int rowCount=0;

            try
            {
                rowCount = command.ExecuteNonQuery();
            }
            catch (SqlException) { throw; }
            finally{
                command.Dispose();
                this.Close();
            }

            return rowCount;
        }
Пример #2
0
        public SqlDataReader ExecuteReader(QueryParameter queryParam)
        {
            this.Open();
            SqlCommand command = new SqlCommand(queryParam.commandText);
            command.Connection = _connection;
            command.Parameters.AddRange(queryParam.parameters.ToArray());
            SqlDataReader reader;

            try
            {
                reader = command.ExecuteReader();
            }
            catch (SqlException) {throw;}

            finally
            {
                command.Dispose();
            }

            return reader;
        }