到Postgresql的ODBC连接失败(Visual Studio) [英] ODBC Connection to Postgresql fails (Visual Studio)
本文介绍了到Postgresql的ODBC连接失败(Visual Studio)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我想使用psqlodbc驱动程序访问本地PostgreSQL数据库。
但我无法连接(数据源未找到)。我尝试了驱动程序文档中的示例代码。任何想法为什么会失败?
Hallo,
I want to access a local PostgreSQL database using a psqlodbc driver.
However I cannot connect ("Data Source not found"). I tried the sample code from the driver's documentation. Any ideas why this fails?
Dim szConnect As String = "DSN=localhost;UID=postgres;PWD=root_1234"
Dim cnDB As OdbcConnection = New OdbcConnection(szConnect)
Try
cnDB.Open()
Catch ex As Exception
Debug.Write("Failed")
End Try
推荐答案
根据错误,我认为没有DSN
以该名称( localhost ),检查它。如果它不存在,则以该名称创建一个新的DSN
。
Based on the error, I think there is noDSN
in that name(localhost), check it. If its not exist then create a newDSN
in that name.
如果您的意思是要使用ODBC驱动程序进行连接,请选择正确的连接字符串。
http://www.connectionstrings.com/postgre-sql#p51 [ ^ ]
If you mean you want to connect using ODBC driver, choose proper connection string.
http://www.connectionstrings.com/postgre-sql#p51[^]
尝试使用此postgresql odbc文档中的代码示例连接指南 [ ^ ]
Try to use code example from this postgresql odbc documentation connection guide[^]
这篇关于到Postgresql的ODBC连接失败(Visual Studio)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文