Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add-type -AssemblyName System.Data.OracleClient
- $username = "XXXX"
- $password = "XXXX"
- $data_source = "XXXX"
- $connection_string = "User Id=$username;Password=$password;Data Source=$data_source"
- $statement = "select level, level + 1 as Test from dual CONNECT BY LEVEL <= 10"
- try{
- $con = New-Object System.Data.OracleClient.OracleConnection($connection_string)
- $con.Open()
- $cmd = $con.CreateCommand()
- $cmd.CommandText = $statement
- $result = $cmd.ExecuteReader()
- # Do something with the results...
- } catch {
- Write-Error (“Database Exception: {0}`n{1}” -f `
- $con.ConnectionString, $_.Exception.ToString())
- } finally{
- if ($con.State -eq ‘Open’) { $con.close() }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement