Page 1 of 1

Powershell db connection

Posted: Mon 27 Jul 2020 17:44
by douglass
I'm trying to write a powershell script that uses dotconnect to connect to an Oracle db as a form of monitoring.

Powershell is relatively new to me, but I have a sql server script to base it off, the key part being:

$sqlConnection = New-Object System.Data.SqlClient.SqlConnection;
$sqlConnection.ConnectionString = $ConnectionString;
$sqlConnection.Open();

For dotconnect, I was able to run the following...

Add-Type -Path "Devart.Data.Oracle.dll"
$testObj = New-Object Devart.Data.Oracle.OracleConnection;
$testObj.ConnectionString = "[Redacted]"

... but when I run $testObj.open(), I get the following message:

MethodInvocationException: Exception calling "Open" with "0" argument(s): "Method not found: 'System.String System.AppDomainSetup.get_LicenseFile()'."

How do I indicate to powershell that this is licensed? I couldn't find any documentation on running dotconnect within powershell.

Thanks!

Re: Powershell db connection

Posted: Thu 06 Aug 2020 15:29
by Shalex
Specify the value of the Target framework property of your project:

* if it is .NET Framework, use Devart.* assemblies created by the provider installation at "C:\Program Files (x86)\Devart\dotConnect\Oracle\". Licensing approach is described at https://www.devart.com/dotconnect/oracl ... nsing.html.

* if it is .NET Standard / .NET Core, use Devart.* assemblies downloaded from NuGet via Nuget Package Manager: https://www.nuget.org/packages/devart.data.oracle/. Licensing approach is described at https://www.devart.com/dotconnect/oracl ... ndard.html.