Pergunta

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=127.0.0.1;port=5432;uid=root;pwd=root"
mCon.Open()

I am getting error on mCon.OPen()

Please Help If my parameters are correct?

Foi útil?

Solução

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=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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top