diff --git a/modules/customreports/customreports.module b/modules/customreports/customrepo
index 7c9e570..48a37b0 100644
--- a/modules/customreports/customreports.module
+++ b/modules/customreports/customreports.module
@@ -172,9 +172,21 @@ function customreports_render($type, $node) {
   $args = func_get_args();
   unset($args[0]);
   unset($args[1]);
+
+  $use_db_regex = '/^use (\w+);/i';
+  $custom_db = preg_match($use_db_regex, $node->body, $matches);
+  if($custom_db) {
+    db_set_active($matches[1]);
+    $node->body = str_replace($matches[0], '', $node->body);
+  }
+
   // Allow parameters to be passed as arguments.
   $result = db_query($node->body, $args);
 
+  if($custom_db) {
+    db_set_active();
+  }
+
   while ($item = db_fetch_array($result)) {
     $data[] = $item;
   }
