Search code examples
powershellconnection-stringadvantage-database-server

Advantage Database connection string in Powershell


Does anyone know the right format of the connection string required to connect to the Advantage Database in PowerShell? what even is the driver that needs to be used?

I cant even find any documentation relating to the advantage database, so if anyone has a link to that, I would be very grateful.

EDIT:

I have this code now:

$connectionString = "Driver={Advantage ODBC Driver};Data Source=xxx;"
$connection = New-Object System.Data.Odbc.OdbcConnection
$connection.ConnectionString = $connectionString
$connection.Open()

and it produces this error:

Exception calling "Open" with "0" argument(s): "ERROR [08001] [iAnywhere Solutions][Advantage ODBC Driver]Unable to connect"

At line:4 char:1

+ $connection.Open()

+ ~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : OdbcException

I am pretty sure I am missing something or have got something wrong... I know ODBC driver is set up correctly as other services use it without a hickup...


Solution

  • solved it, posting solution as it might help others:

    instead of 3 lines of code all is needed, before opening connection, is:

    $connection = New-Object System.Data.Odbc.OdbcConnection("DSN=NameOfDSNiWantToUSe")