Click here to Skip to main content
12,447,786 members (62,922 online)
Rate this:
 
Please Sign up or sign in to vote.
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 6-Nov-11 23:35pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

If you mean you want to connect using ODBC driver, choose proper connection string.
http://www.connectionstrings.com/postgre-sql#p51[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Try to use code example from this postgresql odbc documentation connection guide[^]
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 10 Sep 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100