Connect to another database in WordPress using the wpdb class

In WordPress the $wpdb object can talk to any number of tables, but only within database WordPress is installed. In case you need to connect to another database, you will have to instantiate your own object from the wpdb class with the appropriate connection details:

$mydb = new wpdb( 'username' , 'password' , 'database' , 'localhost' );


Once the connection is made you can access the database and its tables as you would in any WordPress database:

$rows = $mydb->get_results("SELECT field1,field2 FROM myTable WHERE field3=1");
foreach ($rows as $row) {
  echo $row->field1;

This code can be in plugins, templates, themes and almost anywhere else inside the WordPress code.

SCOM 2007 R2 create/install databases using DBCreateWizard.exe – even remotely!

Instead of using MSI to create SCOM databases, you have the option to use DBCreateWizard.exe which can be found in the SupportTools folder. DBCreateWizard also gives the option to create the databases remotely when using command line like shown below:


DBCreateWizard.exe DBType:"Operations Manager Database" SQLInstance:<SQLinstance> DBName:<SQLdbName> ManagementGroup:<ManagementGroup> UserGroup:<AD_AdminGroup> DBCreate DBSize:<SQLDBsize> DBPath:<SQLdataPath> LOGPath:<SQLlogPath>



DBCreateWizard.exe DBType:"Operations Manager Data Warehouse Database" SQLInstance:<SQLinstance> DBName:<SQLdbName> DBCreate DBSize:<SQLDBsize> DBPath:<SQLdataPath> LOGPath:<SQLlogPath>

DBCreateWizard.exe creates a log file starting with dbCreateWiz in the temp folder.

If DBCreateWizard.exe is started without command line parameters the GUI will show.
NOTE: It is not possible to create databases remote from the GUI!