Click here to Skip to main content
11,409,766 members (61,716 online)
Rate this: bad
good
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 7-Nov-11 0:35am
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  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 270
1 OriginalGriff 255
2 Maciej Los 138
3 Andy Lanng 105
4 Sascha Lefévre 95
0 Sergey Alexandrovich Kryukov 8,771
1 OriginalGriff 6,905
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 7 Nov 2011
Copyright © CodeProject, 1999-2015
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