Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

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";    
    

    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();
     

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();
Note:

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

Feedback