This is my code to connect to an Oracle database:
[Reflection.Assembly]::LoadFile("E:oracleproduct.2.0ODP.NETbin.xOracle.DataAccess.dll") $constr = "User Id=system;Password=password;Data Source=SERVERINST" $conn= New-Object Oracle.DataAccess.Client.OracleConnection($constr)
First line is working fine. I can see the assembly is loading and GAC is true.
Up to the second line there is no error.
But when it reaches the 3rd line, I am getting this error:
New-Object : Exception calling “.ctor” with “1” argument(s): “The type initializer for ‘Oracle.DataAccess.Client.Oracle Connection’ threw an exception.
$conn= New-Object <<<< Oracle.DataAccess.Client.OracleConnection($constr)
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Can anybody advise me on this.
Powershell version is 2.