* In Main.prg PUBLIC lnSql AS Integer lnResult = SQLCONNECT('DB1',.T.) && Default connection IF lnResult < 1 * Write message to errolog and quit ENDIF oMainForm = CREATEOBJECT('MainMenuForm') oMainForm.Show() READ EVENTS
* In MainForm's menu, BAR 'Choose Client' PROMPT DB1..DBn * The code in all these menu options goes like this: SQLDISCONNECT(0) && Close all open connections lnResult = SQLCONNECT('DB1',.T.) && or DB2, DB3...DBn IF lnResult < 1 * Write message to errolog and quit ENDIFFrom the menu in MainMenuForm the user then opens a form(class), let's call it MyForm, which in it's load method opens a number of remote views with
USE MyView1 IN 0 CONNSTRING lnSQlI'm using private datasessions, and the views are closed in the unload event of MyForm.
>>* Main prg >>Public lnHandle >>lnHandle = SQLCONNECT('SomeDataSource',.T.) >> >>oMainForm = CREATEOBJECT('MainmenuForm') >>READ Events >> >>CLOSE Database >>lnResult = SQLDISCONNECT(lnHandle) >>>>