Connect to the Thereforeâ„¢ Server |
Scroll |
A connected TheSever instance is needed whenever information is read from or written to the database. Therefore, virtually every Thereforeâ„¢ API client application declares a TheServer instance and connects to it before using other classes and methods in the Thereforeâ„¢ API. As most applications need only one server instance, consider declaring your server static/Shared or using the singleton design pattern. The TheServer instance automatically disconnects when the instance is destroyed. It is, however, considered good practice to disconnect when you are done using the server. Here is a general outline for working with the Thereforeâ„¢ Server.
|
Requirements and Assumptions: User "Test" in the domain "Thereforeâ„¢" exists in your Windows Active Directory. If these assumptions do not apply to your system or configuration please replace them with appropriate values when copying the code samples below. Visual Basic Imports Therefore.API '...
' 1. Declare and initialize a new TheServer instance Dim server As New TheServer
' 2A. Connect with the current user account server.Connect(TheClientType.CustomApplication)
' or 2B. Connect with a specified user account and password ' server.Connect(TheClientType.CustomApplication, _ ' 'Domain\\Test', 'masterkey')
' 3. Work with the Thereforeâ„¢ Server ' ... ' ...
' 4. Disconnect server.Disconnect() C# using Therefore.API; //...
// 1. Declare and initialize a new TheServer instance TheServer server = new TheServer();
// 2A. Connect with the current user account server.Connect(TheClientType.CustomApplication);
// or 2B. Connect with a specified user account and password // server.Connect(TheClientType.CustomApplication, // "Domain\\Test", "masterkey");
// 3. Work with the Thereforeâ„¢ Server // ... // ...
// 4. Disconnect server.Disconnect(); |
Connect Property Use the Connected property to check if the server is currently connected.
Connect Using Advanced Options Several overloads are available for the Connect method, allowing you to also specify node IP address and alias and to show a login dialog. Please see the TheServer.Connect overload list for details. |