Riz Riz - 1 year ago 447
Vb.net Question

How to Connect PostgreSQL with VB.NET Application

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

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

I am getting error on mCon.OPen()

Please Help If my parameters are correct?

Riz Riz
Answer Source

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::

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

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