如何连接 PostgreSQL 和 VB.NET 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21139796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 17:23:40  来源:igfitidea点击:

How to Connect PostgreSQL with VB.NET Application

vb.netpostgresqldatabase-connectionpgadmin

提问by Riz

I want to connect my VB.NET windows application with PostgreSQL 9.3 Beibg a beginner i am unable to do it through ODBC, and Npgsql

我想将我的 VB.NET windows 应用程序与 PostgreSQL 9.3 Beibg 连接起来 初学者我无法通过 ODBC 和 Npgsql 做到这一点

Dim mDAKap As New Odbc.OdbcDataAdapter
Dim mCon As New Odbc.OdbcConnection
mCon.ConnectionString = "Dsn=PostgreSQL30;database=public;server=127.0.0.1;port=5432;uid=root;pwd=root"
mCon.Open()

I am getting error on mCon.OPen()

我在 mCon.OPen() 上遇到错误

Please Help If my parameters are correct?

请帮忙如果我的参数是正确的?

回答by Riz

Got my answer from another source, Writing here for other beginners like me, to save their time:

从另一个来源得到我的答案,在这里为像我这样的其他初学者写作,以节省他们的时间:

First install ODBC driver (get it here http://www.postgresql.org/ftp/odbc/versions/msi/) After installing 32-bit driver::

首先安装 ODBC 驱动程序(在这里获取它http://www.postgresql.org/ftp/odbc/versions/msi/)安装 32 位驱动程序后:

Dim MyCon As New Odbc.OdbcConnection
MyCon.ConnectionString = "Driver={PostgreSQL ANSI};database=database_name;server=127.0.0.1;port=5432;uid=postgres;sslmode=disable;readonly=0;protocol=7.4;User ID=postgres;password=password;"

MyCon.Open()
        If mCon.State = ConnectionState.Open Then
            MsgBox("Connected To PostGres", MsgBoxStyle.MsgBoxSetForeground)
        End If