CreateConnection (Method)

Applies To:

Application

Description:

Use this method to create an Interactive Reporting database connection file for a relational database, which is not automatically associated with a Data Model. CreateConnection() returns an Interactive Reporting database connection file. Refer to the Connection (Object) for a complete list of its methods and properties.

This method does not allow you to create an Interactive Reporting database connection file for a multi-dimensional database (OLAPQuery or CubeQuery).

Note:

The Application.CreateConnection() object model syntax is not supported in an Interactive Reporting document file deployed in the EPM Workspace.

Syntax:

Expression.CreateConnection() As Connection

Expression Required:

An expression that returns an Application object

Example:

This example shows how to create a connection from scratch, save it as an. Interactive Reporting database connection file and use it as the current connection. In this example, the host name uses the ODBC data source name Bookmart:

var myCon = CreateConnection()
myCon.Api = bqApiODBC
myCon.Database = bqDatabaseODBC
myCon.HostName = "Bookmart"
myCon.SaveAs("c:\\temp\\bookmart.oce")
var MyQuery = ActiveDocument.Sections.Add(bqQuery)
MyQuery.DataModel.Connection.Open("c:\\temp\\bookmart.oce")
MyQuery.DataModel.Connection.Connect()