找不到数据源名称

时间:2012-12-03 17:43:18

标签: vb.net postgresql odbc

在vb.net控制台应用程序(x64)上使用odbc connector(x64)连接到postgresql数据库时遇到问题,错误, http://www.sumarlidason.com/tmp/120312/odbc_capture1.png

    Dim ConnectionString = "Driver={PostgreSQL UNICODE};Server=myPGSrv;Port=5432;Database=dbDefault;Uid=postgres;Pwd=pw;"
    'Dim ConnectionString = "ODBC;dsn=PostgreSQL35W"
    conn = New OdbcConnection(ConnectionString)

    'Open connection to an instance of the PostgreSQL database.
    Try
        conn.Open()
    Catch Ex As Exception
        MsgBox(Ex.Message)
    End Try

    Dim commonOdbcCommand = New OdbcCommand
    commonOdbcCommand.Connection = conn
    conn.Close()

另外,我在控制面板中配置了数据库,请看这里.. http://sumarlidason.com/tmp/120312/odbc_capture.png

1 个答案:

答案 0 :(得分:0)

正确的连接字符串:

Dim conn As New OdbcConnection("DSN=PostgreSQL35W")