Getting info from an external database - Base table or view not found
I know you answered your own question with a solution -- here is additional info.

The helper functions db_select(), db_update(), db_insert(), db_merge() all use the default database connection defined in settings.php. As you pointed out you can use db_set_active() to set an active database within a given scope of code. I personally dont like this approach, because X months from writing the code you will forget that, "oooohhh I used db_set_active X lines above" and run into annoying maintenance issues.

There is another solution, dont simply use the helper db functions. Use their parent Objects, which they are wrapping ... as in below:

    // 'remote_database' is a 2nd db connection defined in settings.php
    $query = Database::getConnection('default', 'remote_database')-&gt;select('survey_item', 'si');
$query-&gt;fields('si', array('item_id', 'presentation_order', 'question_type', 'stem', 'choice_1','choice_2', 'choice_3', 'choice_4', 'choice_5', 'choice_6', 'choice_7', 'choice_8'));
$query-&gt;condition('survey_id', $current_row-&gt;survey_id);
$query-&gt;orderBy('presentation_order', 'ASC');
$current_row-&gt;form_items = $query-&gt;execute()-&gt;fetchAll();


So you can create a Query as I have above by specifying the connection first. You may do this for all ->select() or ->update() or ->insert() functions which drupal supplies wrappers for.

Or, you can even pass as a 3rd argument to a SelectQuery() constructor the connection to use for the query, see the docs here:

http://api.drupal.org/api/drupal/includes--database--select.inc/class/SelectQuery/7

  // This is the constructor for SelectQuery() from select.inc
  public function __construct($table, $alias = NULL, DatabaseConnection $connection, $options = array()) {
$options['return'] = Database::RETURN_STATEMENT;
parent::__construct($connection, $options);
$this-&gt;where = new DatabaseCondition('AND');
$this-&gt;having = new DatabaseCondition('AND');
$this-&gt;addJoin(NULL, $table, $alias);


}

So you can also start a db_select() query as follows to tie it to a non default connection in another means:

$query = new SelectQuery('my_table', 'table_alias', Database::getConnection('default', 'remote_database'));
// other things you build onto your query
// $query-&gt;addJoins(...); $query-&gt;fields(...); ...
return $query-&gt;execute()-&gt;fetchAll();


So in a nutshell -- the db helper functions are convenience when talking to 1 database. Beyond that, you can specify per-query what connection to use ... if you like more fine control of your queries and not use db_set_active() all over the place.