ODBC Data Source (IOdbcDataSource)
Methods
- AddAttribute (string name, string value) - IOdbcAttribute Adds or updates an ODBC data source attribute. Returns the created or updated IOdbcAttribute.
- RemoveAttribute (string name) Removes an ODBC data source attribute by its name.
Properties
- Attributes (SAFEARRAY(Variant)) {get} Returns an array of IOdbcAttribute objects for this data source.
- DriverName (string) {get}{set} Gets or sets the name of the ODBC driver used by this data source. The value must match an existing ODBC driver entry.
- Name (string) {get}{set} Gets or sets the display name of the ODBC data source.
- RegisterPerSystem (bool) {get}{set} Gets or sets whether the ODBC data source is registered system-wide (true) or per-user (false).
Sample commands
# IAdvinstProject automation $advinst = New-Object -ComObject "AdvancedInstaller" $project = $advinst.CreateProject($advinst.ProjectTypes.Enterprise) # Intermediate steps # Create APPDIR\ODBC resources and add files from a local folder $project.PredefinedFolders.ApplicationFolder.CreateFolder("ODBC resources") | Out-Null $project.FilesComponent.AddFolderContentS("APPDIR\ODBC resources\printer_driver", "F:\cmdlet\res\ODBC resources\printer_driver") # Add an ODBC Driver (assumes the DLL is among project files) $driverDll = $project.FilesComponent.Files | ? { $_.Name -eq "AnyDeskPrintDriverRenderFilter.dll" } $null = $project.ODBC.NewDriver("My ODBC Driver", $driverDll) # Add a new ODBC Data Source and configure it $null = $project.ODBC.NewDataSource("My Datasource") $ds = $project.ODBC.DataSources[0] $ds.DriverName = "My ODBC Driver" # must match an existing driver entry $ds.RegisterPerSystem = $false # per-user DSN $null = $ds.AddAttribute("Server", "myserver") $null = $ds.AddAttribute("Port", "1433") # List attributes and optionally remove one $ds.Attributes $ds.RemoveAttribute("Port") $project.SaveAs("F:\cmdlet\output\DemoProject Enterprise.aip")