System.Data.OracleClient and powershell


i'm trying use powershell retrieve data local oracle server. when try use oracledataadaptor, fill data set, error need have oracle cliet software version 8.1.7. can fix installing odp.net, huge installation. need scrip portal. have looked using oracle instant client, c# tutorial found looks these need included in same directory executable. since powershell not operate same way, can give me advice how can deploy portable script can connect oracle 10g without type of software installation?

				[void][system.reflection.assembly]::loadwithpartialname("system.data.oracleclient")    				# connection information  				$connectionstring = "data source=serverip;user id=user_name;password=password"    				#standard sql query syntax  				$querystring = "select * table"    				$oracleconnection = new-object system.data.oracleclient.oracleconnection($connectionstring)  				$dtset = new-object system.data.dataset  				$oracleadapter = new-object system.data.oracleclient.oracledataadapter($querystring, $oracleconnection)    				[void]$oracleadapter.fill($dtset)  				  				  exception calling "fill" "1" argument(s): "system.data.oracleclient requires oracle client software version 8.1.7  or greater."  @ line:1 char:42  +                 [void]$oracleadapter.fill <<<< ($dtset)      + categoryinfo          : notspecified: (:) [], methodinvocationexception      + fullyqualifiederrorid : dotnetmethodexception

hello!
it better use oracle data provider .net (odp.net):

$assemblyfile = "c:\oracle\product\10.2.0\client_1\odp.net\bin\2.x\oracle.dataaccess.dll"  $connectionstring = "user id=username;password=password;data source=server;persist security info=true"  $commandtext = "select * table"  [reflection.assembly]::loadfile($assemblyfile) | out-null  $oracleconnection = new-object -typename oracle.dataaccess.client.oracleconnection  $oracleconnection.connectionstring = $connectionstring  $oracleconnection.open()  $oraclecommand = new-object -typename oracle.dataaccess.client.oraclecommand  $oraclecommand.commandtext = $commandtext  $oraclecommand.connection = $oracleconnection  $oracledataadapter = new-object -typename oracle.dataaccess.client.oracledataadapter  $oracledataadapter.selectcommand = $oraclecommand  $dataset = new-object -typename system.data.dataset  $oracledataadapter.fill($dataset) | out-null  $oracledataadapter.dispose()  $oraclecommand.dispose()  $oracleconnection.close()  $dataset.tables[0]




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

Failed to delete the test record dcdiag-test-record in zone test.com

Failed to setup initiator portal. Error status is given in the dump data.