Connecting to JADE

A JoobContext object is used to connect to the database. The default no-parameters constructor uses the defaultConnection information specified in the application configuration file. For details, see "Application Configuration File", in Chapter 6.

The following syntax creates a context object using the no-parameters constructor and establishes a connection to the JADE database.

JoobContext context = new JoobContext();

The following syntax establishes a connection using an alternative connection string defined in the application configuration file.

JoobContext context =
    new JoobContext(JoobConnectionStringBuilder.CreateFromConfig("other"));

When a connection is no longer required, the JoobContext object should be disposed of to release the connection back to the pool.

context.Dispose();

If a connection is required only at certain times in the life of the application, you can create a temporary connection with a using statement. The JoobContext object is implicitly disposed of at the end of the using block.

using (JoobContext context = new JoobContext())
{
    // access the database
}

For details about using non-default connections and specifying connection parameters from your logic, see the JADE .NET API documentation (that is, the JadeDotNetAPI.chm file in the installed JADE documentation directory; for example, C:\Jade\JADE Docs\documentation).