The steps to connect to PostgreSQL from .NET are as follows
- Download the odbc driver from http://www.postgresql.org/ftp/odbc/versions/msi/
- Run the installer
Connection string:
Dim hostname As String = "localhost"
Dim port As String = "5432"
Dim user As String = "myuser"
Dim pass As String = "mypass"
Dim db As String = "myDB"
Dim connstr As String = Nothing
connstr = "DRIVER={PostgreSQL ANSI};SERVER=" + hostname + ";UID=" + myuser + ";PWD=" + mypass + ";DATABASE=" + db
Dim DB_connection As Odbc.OdbcConnection = Nothing
DB_Connection = New OdbcConnection(connstr)
'Open the connectionDB_Connection.Open()
Enjoy~
Mehdi
No comments:
Post a Comment