You got the help already. 1. Pass the database objects as pointers (or references) to the dialog and do the DB work directly inside dialog. 2. Use a messaging mechanism (not especially Windows messages, although could work too) to signal back from dialog to the object that contain your variable m_pRecSet to "do the DB work". 3. Use a separate class that does the DB work, declared by the application object, main window object or where you see this fit, and use a messaging mechanism back and forth to/from this object to any object that require "DB services". Whenever a DB operation needs to be performed, you must have the means to retrieve and use the DB object, either directly (1), via accesors of other objects (2), or using a convenient object that encapsulates the DB services (3). The solution is up to you, as well as what kind of services can be performed - direct brute queries formatted elsewhere, or using more specialized business logic oriented derived classes. I suggest you to implement a hierarchy like: Connection Statement StatementWithResults Recordset StoredProcedure ... (whatever you like) as well as your business objects which can derive from StatementWithResults (1 row in a table) or Recordset for collections.