Click here to Skip to main content
11,634,796 members (66,249 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 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  

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

  Print Answers RSS
0 OriginalGriff 8,736
1 Sergey Alexandrovich Kryukov 8,419
2 Mika Wendelius 6,845
3 F-ES Sitecore 2,354
4 Suvendu Shekhar Giri 2,205


Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | 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