Method DacSession():new() Professional
Creates a DacSession object and connects it to a server.
:new( [<cConnectString>], [<lDefault>] ) --> oSession // Supported for backwards compatibility (ADSDBE only): :new( <cDBE>, <cServerDrive> ) --> oSession
|DBE *)||The database engine for accessing the remote data source|
|SERVER||The server name where the data source resides|
|UID||The user ID required for login|
|PWD||The password required for login|
|DSN||ODBC datasource name|
|DRIVER||ODBC driver name|
|DB||The database on the server to connect with|
This method returns an object of the DacSession class.
The method :new() creates a new instance of the DacSession class. If a connection string is assigned to the <cConnectString> parameter, the method also attempts to connect the object to the server specified. The method :isConnected() can be used to determine whether the connection was established successfully. Once the connection is no longer needed, it can be disconnected using the method :disconnect().
Note that :new() supports two parameter interfaces. The second one is supported for backwards compatibility only and should no longer be used.
The default session is important for database operations programmed in command or functional style. USE database and DbCreate() are examples for such commands and functions which do not allow to select the session to be used. In this case, it is the default DacSession object which forwards these requests to the server. A default session has thread-local scope. This means that each thread can have its own default DacSession object in multi-threaded programs.
When no connection string is passed in the <cConnectString> parameter, the DacSession object returned does not manage a connection on its own. Such a session object is used to build a compound session which is a session connected to multiple data sources. This is achieved by using the :addDataSource() method to add the data source object of other DacSession objects to the compound DacSession object.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.