Click here to Skip to main content
15,851,902 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

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)
Catch ex As Exception
End Try

Based on the error, I think there is no DSN in that name(localhost), check it. If its not exist then create a new DSN in that name.
Share this answer
If you mean you want to connect using ODBC driver, choose proper connection string.[^]
Share this answer
Try to use code example from this postgresql odbc documentation connection guide[^]
Share this answer
George Jonsson 10-Sep-15 5:16am    
Only four years late with your solution.
Don't pick up old questions, please.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900