SQL Database Server (Connections, Queries & Scripts)

Overview

The SQL Database Server area allows you to configure database connections, queries, and scripts that will be executed during installation. It corresponds to the Database Server view in Advanced Installer.

The following object types are available:

  • Custom Connection – configure a connection manually using a connection string.
  • Predefined Connection – configure a connection by selecting from supported database providers (SQL Server, MySQL, Oracle, etc.).
  • SQLite Connection – configure a lightweight, file-based SQLite database connection.
  • SQL Query – define SQL statements that execute against a connection.
  • SQL Script – define inline or external SQL scripts with advanced control over execution order and error handling.

These objects are created under the SqlDatabasesComponent and appear in the Database Server view in Advanced Installer.

Database server

Methods

  • NewCustomConnection (string name) → ISqlCustomConnection Creates a new custom connection with the specified display name.
  • NewPredefinedConnection (string name) → ISqlPredefinedConnection Creates a new predefined connection with the specified display name.
  • NewSQLiteConnection (string name) → ISqliteConnection Creates a new SQLite connection with the specified display name.
  • DeleteDatabaseObject (Variant item) Deletes a database server object (connection, query, or script). Pass the actual object instance returned by the collections below.

Properties

  • CustomConnections (SAFEARRAY(Variant)) {get} Returns an array of ISqlCustomConnection objects.
  • PredefinedConnections (SAFEARRAY(Variant)) {get} Returns an array of ISqlPredefinedConnection objects.
  • SQLiteConnections (SAFEARRAY(Variant)) {get} Returns an array of ISqliteConnection objects.
  • Queries (SAFEARRAY(Variant)) {get} Returns an array of ISqlQuery objects defined in the component.
  • Scripts (SAFEARRAY(Variant)) {get} Returns an array of ISqlScript objects defined in the component.

Sample commands

# SQL Database Server (Connections, Queries & Scripts)

$advinst  = New-Object -ComObject "AdvancedInstaller"
$project  = $advinst.CreateProject($advinst.ProjectTypes.Enterprise)

# Create connections
$customConn = $project.SqlDatabasesComponent.NewCustomConnection("CustomConn")
$predefConn = $project.SqlDatabasesComponent.NewPredefinedConnection("PredefConn")
$sqliteConn = $project.SqlDatabasesComponent.NewSQLiteConnection("SQLiteConn")

# Add queries/scripts to a connection
$query  = $customConn.NewQuery("Init Query")
$script = $sqliteConn.NewScript("Schema Setup")

# Inspect collections
$project.SqlDatabasesComponent.CustomConnections
$project.SqlDatabasesComponent.PredefinedConnections
$project.SqlDatabasesComponent.SQLiteConnections
$project.SqlDatabasesComponent.Queries
$project.SqlDatabasesComponent.Scripts

# Delete an object (pass the object, not the name)
# $project.SqlDatabasesComponent.DeleteDatabaseObject($query)

$project.SaveAs("F:\cmdlet\output\DatabaseServer.aip")

Topics

  • SQL Custom Connection (ISqlCustomConnection)
    Interface for defining and managing custom SQL database connections, including inline queries and script execution.
  • SQL Predefined Connection (ISqlPredefinedConnection)
    Interface for creating and managing predefined SQL connections with configurable server, database, driver, and authentication options.
  • SQLite Connection (ISqliteConnection)
    Interface for creating and managing SQLite database connections, including queries and scripts executed at install time.
  • SQL Query (ISqlQuery)
    Interface for defining SQL queries attached to a database connection, with support for inline scripts, external script files, token replacements, and data-binding properties.
  • SQL Script (ISqlScript)
    Interface for defining SQL scripts attached to a database connection, supporting inline or external script execution with advanced control over conditions, timing, transactions, and error handling.