Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (login required).

Connecting to Caché

Whether your application uses the object interface or the relational interface, it must first connect to Caché. To connect, the application must create a CacheConnection object and supply it with a connection string. To then open the connection, the application invokes the CacheConnection Open method:

  1. Create a connection string. A typical connection string looks like the following:

    
    string connectionString
     = "Server = localhost; Port=1972;" +
                   "Log File = c:\\Phonebook.log; Namespace = USER;" +
                   "Password = SYS; USER ID = _SYSTEM";    
    
    Copy code to clipboard

    Please note that the log file must be placed in a directory that the application is able to write to.

  2. Initialize a CacheConnection object using the connection string and then open the connection using Open:

    
     CacheConnection cnCache = new CacheConnection(connectionString);
     cnCache.Open();
     
    Copy code to clipboard

You can also use the ConnectDlg method to retrieve the connection string from the user at runtime. The method displays the standard Caché connection dialog boxes. The user then enters the connection string information into the boxes at runtime.


string connectionString = CacheConnection.ConnectDlg();
CacheConnection cnCache = new CacheConnection(connectionString);
cnCache.Open();
Copy code to clipboard
Note:

The general format for the connection string is “Server = <server>; Port=<port>; Log File = <log>; Namespace = <namespace>; Password = <pwd>; User ID = <user>”

FeedbackOpens in a new window