........
'@
$anError = $false;
[Reflection.Assembly]::LoadFile($psh + "\dll\Oracle.DataAccess.dll")
$conn= New-Object Oracle.DataAccess.Client.OracleConnection($oracleConstr);
$conn.Open();
#the first thing is lookup connection information for VCenter Server:
$sql = "SELECT sc.scsystem, sc.scIP, sc.scAccount, sc.scPassword FROM SystemConfigure sc WHERE sc.scsystem = 'vcenter'" +
" OR sc.scsystem = 'firewall'" +
" OR sc.scsystem = 'unix command gateway'" ;
$vcenter = $null;
$unixServer = $null;
$firewall = $null;
.........
此脚本是在windows2003虚拟机里运行的,功能是用来产出虚拟机的,调用脚本执行。powershell脚本连接oracle数据库是ok的,调用dll\Oracle.DataAccess.dll文件也没有问题,但是连接后,走到$conn.Open()的时候报如下的错误。各位大虾看到后说下原因,在线跪求。。。
GAC Version Location
--- ------- --------
True v2.0.50727 C:\WINDOWS\assembly\GAC_32\Oracle.DataAccess\2.102.2.20__89b483f429c47342\Oracle.DataAccess.dll
Exception calling "Open" with "0" argument(s): ""
At E:\powerShellScript\CreateVirtualMachineByVMOrderID.ps1:71 char:11
+ $conn.Open <<<< ();
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
您的$oracleConstr值是什么,先在外面测试一下,能不能连接?
是连接oracle的字符串值,用户名,密码,数据库的值,$oracleConstr值是有的,可以读取。但就是到$conn.Open()这里就不对了,报错,很郁闷。