Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Oracle Connection String with example usage

By: a guest on Nov 16th, 2012  |  syntax: Power Shell  |  size: 0.66 KB  |  hits: 82  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.                                                 }