Skip to content

Set database settings

This function is used to define database settings and connection methods.

The settings are saved in the registry for the current Windows user (under HKEY_CURRENT_USER), in the same place where the CapaInstaller Console stores its database connection for that user. This means that:

  • The settings remain in effect for later scripts run by the same Windows user, and for the CapaInstaller Console started by that user.
  • If you don’t call this function, the SDK connects to the database that is already saved for the current Windows user, for example by the CapaInstaller Console.

Call this function before any other SDK function in your script.

SetDatabaseSettings(Byval Server as String, Byval Database as String, Byval SQLServerAuthentication as Boolean, Optional Byval UserName as String = “”, Optional Byval Password as String = “”) as Boolean

Server (String)

The SQL Server you want to connect to

Database (String)

The database you want to open

SQLServerAuthentication (Boolean)

True if you want to connect using SQL Server authentication (username and password)

False if you want to connect using Windows Authentication. The script then connects as the Windows user who runs it.

UserName (String)

The name of the SQL Server account to connect with. Only used when SQLServerAuthentication is True.

Password (String)

The password corresponding to the above username. Only used when SQLServerAuthentication is True.

Returns a boolean value. True if succeeded. If the settings can’t be saved, the function raises an error.

The function doesn’t test the connection. A wrong server or database name is reported by the first function that reads from the database.

Dim bStatus
Dim oCMS
Set oCMS = CreateObject("CapaInstaller.SDK")
' Windows Authentication
bStatus = oCMS.SetDatabaseSettings("WSTST10","CMS",False)
' SQL Server authentication
' bStatus = oCMS.SetDatabaseSettings("WSTST10","CMS",True,"<username>","<password>")