|
Object DtoSession is the root object for most DTO operations. It represents and manages a connection to a Pervasive.SQL database engine.
|
Connected
|
Returns a Boolean indicating whether the Session object is connected to the Pervasive.SQL engine.
True = connected
False = not connected
|
|
Error
|
Returns the error of the last method call. Pass the result of the method call and a dtoResult string will be returned that explains the error.
See DtoResult for a listing of these error codes.
|
|
ServerName
|
Gets or sets the server name of a DtoSession object.
|
|
UserName
|
Sets the user name for an object.
|
|
Password
|
Sets the password for a session.
|
A DtoSession object is the starting point for all operations except dictionaries. You use DtoSession to make connection to servers, obtain configuration information such as categories and setings, explore databases and DSNs, and to monitor Pervasive.SQL usage information.
To use DtoSession, first instantiate your object and use the Connect method to specify a server for the session object.
The user name and password you use for the session connect is for the machine only. This does not authenticate you to any Pervasive.SQL database.
Note
If instantiating this object using ASP or if you use the CreateObject method in Visual Basic, the progid of DtoSession is "DTO.DtoSession.2" (DTO version 2) or "DTO.DtoSession.1" (DTO version 1). See DTO2 for information on the differences between the two versions.
' instantiate session object Dim my_session as New DtoSession ' connect to a server result = my_session.Connect("myserver", "username", "password") ' check for good connection using the Error property if Not (result = Dto_Success) Msgbox"Could not connect to the server. Error was "+ my_session.Error(result) ' now use your session object to obtain ' category and database collections Dim my_categories as DtoCategories Dim my_databases as DtoDatabases Set my_categories = my_session.Categories Set my_databases = my_session.Databases
DtoCategories Collection
DtoServices Object
DtoMonitor Object
DtoDatabases Collection
DtoDSNs Collection
Open a connection to a server.
|
result
|
DtoResult long value indicating the result of the method call. Use the Error property to obtain a description for the result.
|
Since connections to servers can fail for a variety of reasons, be sure to check the return value for this method and take appropriate action programmatically.
If username and password are not specified, an attempt will be made to login as a guest. If such an attempt is successful, some functionality will not be available.
Check the isConnected property in order to see whether the session is currently connected.
Dim result as DtoResult Dim my_session as New DtoSession result = my_session.Connect("myserver", "smook", "1234"); Dim result as DtoResult Dim my_session as New DtoSession my_session.UserName="smook" my_session.Password="1234" my_session.ServerName="myserver" result = my_session.Connect
End a connection to a server.
|
result
|
DtoResult long value indicating the result of the method call. Use the Error property to obtain a description for the result.
|
This method should be called for every server to which you are connected prior to using the session object to connect to another server, or exiting the application.
Dim result as DtoResult Dim my_session as New DtoSession result = my_session.Connect("myserver", "username", "pw"); ' ' perform operations here ' result = my_session.Disconnect
Obtains a DtoSetting object using a setting id.
|
Object
|
DtoSession object
|
|
setting_id
|
A valid setting id. Each DtoSetting object has a property SettingID that uniquely identifies it. If you are trying to obtain all settings for a particular category, use the Settings property of the DtoCategory Object. This method is useful if you already know a particular setting you wish to obtain and you have previously stored its setting_id.
|
This method is useful for obtaining a specific setting without having to first obtain a category and then searching through a DtoSettings collection.
Dim my_session as New DtoSession Dim result as DtoResult result = my_session.Connect("myserver", "username", "pw"); ' stored_id is a variable representing a setting id ' that your program previously stored Dim my_setting as DtoSetting Set my_setting = my_session.GetSetting(stored_id); If my_setting is Nothing then MsgBox "Invalid setting" End If
|
Chapter contents
Prev topic: Establishing a DTO Session
|