Windows Server 2008 R2 上的 powershell 2.0 无法使用 OLEDB 连接
我在 XP 机器上开发了一个 powershell 应用程序,该应用程序与 Sybase 服务器建立 OLEDB 连接以提取数据,然后将数据插入到 SQL Server 2008 数据库实例中。调试此脚本并确保进程正确运行后,我将脚本移至新的 Windows Server 2008 R2 机器中。为了连接到 Sybase 实例,我安装了 Sybase 12.5.2 客户端,就像在 XP 机器上所做的那样。但是,运行脚本失败并显示以下消息: 使用“0”参数调用“open”时出现异常:“'Sybase.ASEOLEDBProvider.2'提供程序未在本地计算机上注册。
基本连接字符串源自connectionStrings.com并在XP上工作,所以我这样做不相信本身存在语法问题,因此,我使用以下命令手动注册了 OLEDB dll: regsvr32 sydaase.dll
它注册没有错误。
删掉脚本中的相关行,连接逻辑顺序为 $dbConn = 新对象 System.Data.oldeb.oledbConnection $dbConn.connectionString = "Provider=Sybase.ASEOLEDBProvider.2; 服务器名称 = myServer; 端口地址 = xxx; 初始目录 = xxx; 用户 ID = xxx; 密码 = xxxx"
在此示例中,我已将数据替换为 xxx。
我不清楚为什么它在 XP 机器上运行没有问题,但在 Windows Server 机器上却失败了,尽管我遵循了相同的配置过程。
I developed a powershell application on an XP box that made an OLEDB connection to a Sybase server to extract data that is then inserted into a SQL Server 2008 database instance. After debugging this script and ensuring the process operated correctly, I moved the script to a new Windows Server 2008 R2 box. In order to connect to the Sybase instance I installed the Sybase 12.5.2 client as I had done on the XP box. However, running the script failed with the message:
Exception calling "open" with "0" argument(s): "The 'Sybase.ASEOLEDBProvider.2' provider is not registered on the local machine.
The base connection string was derived from connectionStrings.com and worked on the XP so I do not believe there is a syntax issue per se. So, I manually registed the OLEDB dll with the command:
regsvr32 sydaase.dll
it registered with no errors.
Cutting out the pertinent lines of the script, the connection logic sequence is
$dbConn = new-object System.Data.oldeb.oledbConnection
$dbConn.connectionString = "Provider=Sybase.ASEOLEDBProvider.2; server name = myServer; port address = xxx; initial catalog = xxx; user Id = xxx; Password = xxxx"
I have replaced my data with xxx in this example.
I am not clear why this ran without issue on the XP box, but is failing to do so on the Windows Server box though I followed the same configuration process.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我敢打赌,您正在 64 位 R2 计算机上尝试此操作,并使用 64 位 PowerShell 控制台。没有原生 64 位 OLEDB 驱动程序,只有 32 位 - 使用 32 位控制台应该没问题。
I'll wager that you are trying this on a 64 bit R2 machine, and using the 64 bit PowerShell console. There are no native 64 bit OLEDB drivers, only 32 bit - use the 32 bit console and you should be ok.