IODBCComponentCopy link to this sectionLink to this section copied!

OverviewCopy link to this sectionLink to this section copied!

This interface is meant to create, access or delete ODBC components, corresponding to the ODBC view:

Odbc page

The IODBCComponent has the following methods and properties:

Iodbc component

MethodsCopy link to this sectionLink to this section copied!

  • DeleteOdbc (Variant item) Deletes an ODBC entry. The item can be an IOdbcDataSource, IOdbcDriver, or IOdbcTranslator object (as returned by DataSources, Drivers, or Translators).
  • NewDataSource (string dataSourceName) - IOdbcDataSource Creates a new ODBC Data Source with the specified display name and returns the created IOdbcDataSource for further configuration (e.g., type, driver, attributes).
  • NewDriver (string driverName, IFile driverFile) - IOdbcDriver Creates a new ODBC Driver entry using the driver display name and the file object (IFile) that points to the driver DLL. Returns the created IOdbcDriver.
  • NewTranslator (string translatorName, IFile translatorFile) - IOdbcTranslator Creates a new ODBC Translator entry using the translator display name and the file object (IFile) that points to the translator DLL. Returns the created IOdbcTranslator.

PropertiesCopy link to this sectionLink to this section copied!

  • DataSources (SAFEARRAY(Variant)) {get} Returns an array of ODBC Data Source objects (IOdbcDataSource).
  • Drivers (SAFEARRAY(Variant)) {get} Returns an array of ODBC Driver objects (IOdbcDriver).
  • Translators (SAFEARRAY(Variant)) {get} Returns an array of ODBC Translator objects (IOdbcTranslator).

Sample commandsCopy link to this sectionLink to this section copied!

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

# Intermediary steps
# Add ODBC resources to the project
# Create folder in Application Data predefined folder
$odbc_folder = $project.PredefinedFolders.ApplicationData.CreateFolder("ODBC resources")

# Add files to the created folder
# Update path to match your local resources
$project.FilesComponent.AddFolderContentS("APPDIR\ODBC resources\printer_driver", "F:\cmdlet\res\ODBC resources\printer_driver")

# Get the AnyDeskPrintDriverRenderFilter for further usage
# This file will be referenced when adding ODBC Driver and ODBC Translator
# Update filename to match your case
$AnyDeskPrintDriverRenderFilterFile = $project.FilesComponent.Files | ? { $_.Name -eq "AnyDeskPrintDriverRenderFilter.dll" }

$project.ODBC | gm

# Add new ODBC Driver
$project.ODBC.NewDriver("My ODBC Driver", $AnyDeskPrintDriverRenderFilterFile) 
$project.ODBC.Drivers[0].AddAttribute("MaxBufferSize", "2048")
$project.ODBC.Drivers[0].AddAttribute("DriverODBCVer", "03.80")
$project.ODBC.Drivers[0].AddAttribute("AnotherAttribute", "AnotherValue")

$project.ODBC.Drivers[0].RemoveAttribute("AnotherAttribute")

# List all attributes of the first ODBC Driver
$project.ODBC.Drivers[0].Attributes

# Add new ODBC Data Source
$project.ODBC.NewDataSource("My Datasource")

$project.ODBC.DataSources[0].DriverName = "My Datasource Driver"
$project.ODBC.DataSources[0].RegisterPerSystem = $false
$project.ODBC.DataSources[0].AddAttribute("Server", "myserver")
$project.ODBC.DataSources[0].AddAttribute("Port", "1433")

# List all attributes of the first ODBC Data Source
$project.ODBC.DataSources[0].Attributes

# Add new ODBC Translator
$project.ODBC.NewTranslator("My ODBC Translator", $AnyDeskPrintDriverRenderFilterFile)

# List ODBC Translator properties
$project.ODBC.Translators

Topics