如何解决oracle错误 - &quot“用户ID'无效的连接字符串属性“使用PowerShell?
我正在尝试使用PowerShell连接到远程Oracle DB。我安装了以下内容:
ODTwithODAC122011, ODP.Net_Managed_ODAC_122cR1
我有.netFramework 4.8.04084。
正如它在问题中所述的那样,我会收到以下错误:
New-Object : Exception calling ".ctor" with "1" argument(s): "'
User Id' is an invalid connection string attribute"
我尝试了几种连接到Oracle DB的方法。其中一个正在使用[System.Reflection.sembly] :: LoadWithPartialName(“ System.Data.oracleClient”)
> loadWithPartialName(“ System.Reflection.sembly)),但这也会给出一个错误。
代码是:
Add-Type -Path C:\odp.net\managed\common\Oracle.ManagedDataAccess.dll
$query="Select NC_NAME From NC_PROGRAMS FETCH FIRST 10 ROWS ONLY"
$OracleConnectionString = "Data Source=(DESCRIPTION=
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.xx.xx.x)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=Fa1)));
User Id=username ;Password=password"
$connection = New-Object Oracle.ManagedDataAccess.Client.OracleConnection($OracleConnectionString)
$connection.open()
$command=$connection.CreateCommand()
$command.CommandText=$query
$reader=$command.ExecuteReader()
while ($reader.Read()) {
$reader.GetString(1) + ', ' + $reader.GetString(0)
}
$connection.Close()
任何帮助都非常感谢。
I am trying to connect to a remote Oracle db using PowerShell. I installed the following:
ODTwithODAC122011, ODP.Net_Managed_ODAC_122cR1
I have .NetFramework 4.8.04084.
As it states in the question, I get the following error:
New-Object : Exception calling ".ctor" with "1" argument(s): "'
User Id' is an invalid connection string attribute"
I have tried a few different ways of connecting to the Oracle db. One of them being loading the assembly using [System.Reflection.Assembly]::LoadWithPartialName("System.Data.OracleClient")
but that gives an error too.
Code is:
Add-Type -Path C:\odp.net\managed\common\Oracle.ManagedDataAccess.dll
$query="Select NC_NAME From NC_PROGRAMS FETCH FIRST 10 ROWS ONLY"
$OracleConnectionString = "Data Source=(DESCRIPTION=
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.xx.xx.x)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=Fa1)));
User Id=username ;Password=password"
$connection = New-Object Oracle.ManagedDataAccess.Client.OracleConnection($OracleConnectionString)
$connection.open()
$command=$connection.CreateCommand()
$command.CommandText=$query
$reader=$command.ExecuteReader()
while ($reader.Read()) {
$reader.GetString(1) + ', ' + $reader.GetString(0)
}
$connection.Close()
Any help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试删除“断路”和“”之间的空间和“用户ID”。
Try to delete line breakes and space between ";" and "User Id".
Oracle的连接字符串必须如下:
The connection string for Oracle has to be as the following: