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!

PowerShell and ODP.NET - How do run UPDATE and COMMIT commands? ExecuteReader or something else?

d2fbb087-58b1-41da-bf00-50a68f77be8dJan 28 2019 — edited Jan 29 2019

Hello, I'm utterly new here and to Oracle technologies.

I've been using Microsoft PowerShell together with ODP.NET to communicate with Oracle databases.  So far, so good.

Previously, my use cases has been read-only, so I've been using the following general lines of code to read records:

[Reflection.Assembly]::LoadFile("C:\oracle\product\12.1.0\client32_1\ODP.NET\bin\2.x\Oracle.DataAccess.dll")

$ConnectionString = "User Id=someusername;Password=somepassword;Data Source=somedatasource"      

$ConnectionObject = New-Object Oracle.DataAccess.Client.OracleConnection($ConnectionString)

$ConnectionObject.Open()

$SQLQuery = "SELECT * FROM SOME_TABLE"

$SQLCommand = New-Object Oracle.DataAccess.Client.OracleCommand($SQLQuery,$ConnectionObject)

$SQLReader = $SQLCommand.ExecuteReader()

However, now I have need to run an UPDATE SQL command against this same database, obviously followed by a COMMIT.

I'm assuming I don't use the "ExecuteReader" for this?  I can't find an equivalent "ExecuteWriter" method in the ODP.NET for running queries that UPDATE the database.

I realise this is a real n00b question, but if anyone can advise me how I proceed to invoke queries that make changes to the database, I'd be so grateful.

This post has been answered by Mark Williams on Jan 29 2019
Jump to Answer
Comments
Post Details
Added on Jan 28 2019
2 comments
4,527 views