PoshCode Archive  Artifact [9d18851ae3]

Artifact 9d18851ae377978b1196bd43e154f620af41ffe9c9d7650181e3df96314fbdd9:

  • File PowerOracle.ps1 — part of check-in [8a93aec76c] at 2018-06-10 14:19:14 on branch trunk — Retrieve data from an Oracle database into a dataset. (user: dfafadfds size: 925)

# encoding: ascii
# api: powershell
# title: PowerOracle
# description: Retrieve data from an Oracle database into a dataset.
# version: 0.1
# author: dfafadfds
# license: CC0
# x-poshcode-id: 6666
# x-archived: 2017-01-10T16:40:16
# x-published: 2017-01-04T15:47:00
#
# Prerequisite: Install the Oracle Data Provider for .NET > Google it! =)
#
# Load assembly
[System.Reflection.Assembly]::LoadWithPartialName("Oracle.DataAccess")

# Connection information
$ConnectionString = "Data Source=your_server/sid;User Id=user_name;Password=password"

#Standard SQL Query Syntax
$QueryString = "SELECT * FROM table_name WHERE #Case"

$OracleConnection = New-Object Oracle.DataAccess.Client.OracleConnection($ConnectionString)
$dtSet = New-Object System.Data.DataSet
$OracleAdapter = New-Object Oracle.DataAccess.Client.OracleDataAdapter($QueryString, $OracleConnection)

[void]$OracleAdapter.Fill($dtSet)