Click here to Skip to main content
14,739,758 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hallo,

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)
Try
    cnDB.Open()
Catch ex As Exception
    Debug.Write("Failed")
End Try
Posted

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.
   
If you mean you want to connect using ODBC driver, choose proper connection string.
http://www.connectionstrings.com/postgre-sql#p51[^]
   
Try to use code example from this postgresql odbc documentation connection guide[^]
   
Comments
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