PoshCode Logo PowerShell Code Repository

PowerOracle by dfafadfds 3 months ago (modification of post by foureight84 view diff)
View followups from PRUEBA | diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/6665"></script>download | new post

Retrieve data from an Oracle database into a dataset.

Prerequisite: Install the Oracle Data Provider for .NET > Google it! =)

  1. # Load assembly
  2. [System.Reflection.Assembly]::LoadWithPartialName("Oracle.DataAccess")
  3.  
  4. # Connection information
  5. $ConnectionString = "Data Source=your_server/sid;User Id=user_name;Password=password"
  6.  
  7. #Standard SQL Query Syntax
  8. $QueryString = "SELECT * FROM table_name WHERE #Case"
  9.  
  10. $OracleConnection = New-Object Oracle.DataAccess.Client.OracleConnection($ConnectionString)
  11. $dtSet = New-Object System.Data.DataSet
  12. $OracleAdapter = New-Object Oracle.DataAccess.Client.OracleDataAdapter($QueryString, $OracleConnection)
  13.  
  14. [void]$OracleAdapter.Fill($dtSet)

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me