问题描述
我试图在Win 7上从C#.net 4.5 VS2013访问Netezza服务器.
I am trying to access a Netezza server from C# .net 4.5 VS2013 on win 7.
using System.Data.Odbc;
string connstring = "Driver={NetezzaSQL};Server=MyServerIP;Port=5480;Database=MyDBName;Uid=MyID;Pwd=myPWD;ReadOnly=true;";
using (OdbcConnection conn = new OdbcConnection(connstring))
{
conn.ConnectionTimeout = 120;
conn.Open(); // error 08001
Console.WriteLine("OK");
}
I got:
An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in System.Data.dll
Additional information: ERROR [08001] Client unable to establish connection
来自https://msdn.microsoft.com/zh-cn/library/ms715433%28v=vs.85%29.aspx ,我看到错误08001是
From https://msdn.microsoft.com/en-us/library/ms715433%28v=vs.85%29.aspx, I see that error 08001 is
The driver was unable to establish a connection with the data source.
从控制面板-> adm工具->数据源(ODBC),我检查是否已安装NetezzaSQL 7.01.00.3553
From control panel --> adm tools --> Data Sources (ODBC), I checked that I have installed NetezzaSQL 7.01.00.3553
应该为64位,因为在数据源(ODBC -32位)中还有另一个NetezzaSQL驱动程序.
It should be 64 bits, because in Data Sources (ODBC -32 bit) there is another NetezzaSQL driver.
在C:\ Windows \ SysWOW64中,我有nsqlodbc.dll,odbc32.dll和其他相关文件.
in C:\Windows\SysWOW64 I have nsqlodbc.dll, odbc32.dll and other related files.
我的C#代码是为任何CPU构建的.无论我将构建更改为64位还是32位,我都可以相同错误.似乎C#代码找不到驱动程序?
My C# code is built for Any CPU. No matter I changed the build to 64 or 32 bits, I got thesame error. It seems that C# code cannot find the driver ?
我可以从IBM Netezza Aginity工作台使用相同的ID和密码访问相同的服务器和数据库,而不会出现任何问题.
I can access the same server and DB from IBM Netezza Aginity workbench with the same ID and password without any problems.
推荐答案
谢谢您在这里发布.
对于您的问题,请尝试下面的连接字符串.
For your question, please try the connection string below.
Driver={NetezzaSQL};servername=myServerAddress;port=myPortNumber;
database=myDataBase;username=myUsername;password=myPassword;
服务器资源管理器的连接字符串有所不同.请尝试Netezza的连接字符串.
There is something different for connection string of server explorer. Please try the connection string of Netezza.
有关连接字符串的更多详细信息,请参阅文章.
For more details about the connection string, please refer to the article.
我希望这会对您有所帮助.
I hope this would be helpful to you.
最好的问候,
温迪
这篇关于ODBC无法从C#VS2013访问Netezza服务器,但可以从“服务器资源管理器"访问Netezza服务器.在VS2013中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!