Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help Querying an Oracle Database from PowerShell

dbaseukFeb 25 2016 — edited Feb 28 2016

Hi All.

I have set up a server running Windows Server 2008 R2, PowerShell 3.

I would like to query an Oracle 9.2 database from this server using, so i have installed Oracle Data access components version 11.2(X64). I have used this previously to query my oracle database.

My PowerShell script looks similar to the following

$reader = $null

Add-Type -Path "C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342\oracle.dataaccess.dll"

$con = New-Object Oracle.DataAccess.Client.OracleConnection("CONNECTION DETAILS HERE")

$con.Open()

$OracleSQLQuery = "SQL QUERY HERE"

$command = New-Object Oracle.DataAccess.Client.OracleCommand($OracleSQLQuery,$con)

$reader=$command.ExecuteReader()

When i run my script i get the following error Exception calling "ExecuteReader" with "0" argument(s): "Connection must be open for this operation"

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2016
Added on Feb 25 2016
1 comment
2,596 views