SHARE
TWEET

Oracle Connection String with example usage

a guest Nov 16th, 2012 97 Never
  1. #Oracle Strings
  2. [Reflection.Assembly]::LoadFile("C:\oracle\product\10.2.0\client_1\odp.net\bin\2.x\Oracle.DataAccess.dll") #Obviously this path needs to be correct
  3. $constr = "User Id=<>;Password=<>;Data Source=<>"
  4. $conn = New-Object Oracle.DataAccess.Client.OracleConnection($constr)
  5. $conn.Open()
  6. $sSQL = "<Query>"
  7. $command = New-Object Oracle.DataAccess.Client.OracleCommand($sSQL,$conn)
  8.  
  9. #....
  10.  
  11. $reader=$command.ExecuteReader()
  12.         for ($a=0;$a -lt $reader.FieldCount;$a++){}
  13.        
  14.                         While ($reader.read())  {  
  15.                                         $str1=$reader.Getstring(0)  #This is the first column value. You can assign others to Getstring(1)
  16.                                         $Var1 = <Do something with> $str1
  17.                                                 }
RAW Paste Data
Top