Skip to main content

Establishing Connections with .NET

Establishing Connections with .NET

The code below establishes a connection to a namespace named USER. See “Connection Parameter Options” for a complete list of parameters that can be set when instantiating a connection object.

The following simple method could be called to start a connection:

Add code to Instantiate the connection
  public IRISConnection Conn;
  private void CreateConnection(){
    try {
      Conn = new IRISConnection();
      Conn.ConnectionString =
        "Server=localhost; Port=51773; Namespace=USER;"
        + "Password=SYS; User ID=_SYSTEM;";
      Conn.Open();
    }
    catch (Exception eConn){
      MessageBox.Show("CreateConnection error: " + eConn.Message);
    }
  }

Once the object has been created, it can be shared among all the classes that need it. The connection object can be opened and closed as necessary. You can do this explicitly by using Conn.Open() and Conn.Close(). If you are using an ADO.NET Dataset, instances of DataAdapter will open and close the connection automatically, as needed.

Troubleshooting .NET Client Connections

A .NET client that attempts to connect to an InterSystems server needs the following information:

  • A URL that provides the server IP address, port number, and namespace.

  • If the connection uses passwords, you must specify a case-sensitive username and password.

Check the following points if you have any problems:

  • Make sure that the server process is installed and running.

  • Make sure that you know the IP address of the machine on which the server process is running.

  • Make sure that you know the TCP/IP port number on which the server is listening.

  • Make sure that you have a valid username and password to use to establish a connection. (You can manage usernames and passwords using the Management Portal: System Administration > Security > Users).

  • Make sure that your connection URL includes a valid namespace. This should be the namespace containing the classes and data your program uses.

FeedbackOpens in a new tab