|
FoxDataObjects |
Object-Relational Mapping Tool for Visual FoxPro® |
|
|
Disconnect Method |
||
|---|---|---|
|
Closes a connection to a data store.
|
||
|
Remarks |
||
|
This method disconnect the session from the data store. If the active data store is a native Visual FoxPro database, DBC database container is closed along with all database tables in all data sessions. If the active data store is an ODBC connection to a local/remote server, the ODBC connection is closed. Before attempting to disconnect from data store, the Session.BeforeDisconnect event is fired. If this event returns a True value (.T.) disconnection attempt continues, otherwise process is canceled and Session.Disconnect returns False. After disconnection, the AfterDisconnected event fires. Session.Disconnect returns True (.T.) if succeeds or False if disconnection was canceled.
|
||
| Example | ||
|
SET PROCEDURE TO FDO ADDITIVE oServer.ConnectedSessionsOnly=.F. oSession = oServer.NewSession("MyApp.fdo")
oDS=oServer.NewDataSource("MySQL")
IF oSession.Connect(oDS) IF oSession.EnsureDatabaseStatus(4) ? "Session connected, database selected and database schema is UpToDate" ELSE oSession.Disconnect ? "Session disconnected. Database schema is out of date and update failed." ? oSession.Errors.ToString() ENDIF ELSE ? "Cannot connect to datasource" ? oSession.Errors.ToString() ENDIF
|
||
| The sample shows how to get a
disconnected session by setting the Server.ConnectedSessionsOnly
property to false. Then a DataSource object is built for a remote MySQL
database server using the "Contacts" database. The Session.Connect method is called with the datasource object passed as a parameter. If connection is successful, the Session.EnsureDataBaseStatus method will open the connection, check for the database, select the database and check for database schema version. If necessary, it will upgrade the database schema. (Note the CheckLevelStatus passed as a parameter is 4 CHECK_DBINUSEANDTABLESUPTODATE ). In case the database schema cannot be upgraded, the connection is closed with Session.Disconnect.
|
||
|
See Also |
||
| fdoDataSource class | Session.DataSourceLookupMode property | Session.ConnectionMode property | Session.ConnectionLifeTime property | Session.Connect method | Server.NewSession method | Server.ConnectedSessionsOnly property | Session.BeforeDisconnect event | Session.AfterDisconnected event | ||
| Applies to: Session object | ||
|
Send feedback on this topic to RunAhead Technologies For Technical support and product issues please contact us at support@foxdataobjects.com or visit http://www.foxdataobjects.com |
Copyright (c) 2000-2005 RunAhead Technologies