简体   繁体   English

无法使用Ole Db提供程序通过C#查找postgres数据库

[英]Can't find postgres database through C# using Ole Db provider

I'm trying to access some postgresSQL databases set up on a linux server we've set up, previously we've been using access and and SQL server 2008 and connecting just fine with C# Ole Db, but we're trying to see if we can make the move to postgres since it would be more convenient. 我正在尝试访问在我们已设置的linux服务器上设置的一些postgresSQL数据库,之前我们一直在使用access和SQL Server 2008并与C#Ole Db很好地连接,但是我们试图查看是否我们可以选择使用postgres,因为这样会更方便。 I can access these databases on the linux machine perfectly fine using ODBC Data Source Administrator which tests the connection the database successfully, PG Admin III which shows all the databases just fine, and also psql can access these databases perfectly fine. 我可以使用ODBC数据源管理器(可以成功测试数据库的连接),PG Admin III(可以很好地显示所有数据库)在linux机器上完美地访问这些数据库,而psql可以很好地访问这些数据库。 However when I try to connect using Ole DB through Visual Studio and the connection string something like: 但是,当我尝试通过Visual Studio使用Ole DB和连接字符串进行连接时,如下所示:

"Provider=PostgresSQL OLE DB Provider;Server=192.168.0.64:5432;location=FRANK;User ID=ourusername;password=ourpassword;timeout=1000;" “ Provider = PostgresSQL OLE DB提供程序;服务器= 192.168.0.64:5432;位置= FRANK;用户ID =我们的用户名;密码=我们的密码;超时= 1000;”

I got this from connectionstrings.com and they've never let me down before. 我是从connectionstrings.com获得的,他们之前从未让我失望过。 I've tried multiple variations, searched for problems that other people had with their connections strings online, and changed it accordingly, but I still get the same error: 我尝试了多种变体,在网上搜索其他人的连接字符串时遇到的问题,并进行了相应的更改,但是我仍然遇到相同的错误:

FATAL: database "FRANK" does not exist 严重:数据库“ FRANK”不存在

Don't know why I get this error it's obviously there. 不知道为什么我得到这个错误,它显然在那里。 The only thing that's different about this compared to the other method of connection is the provider or that it's done through visual studio. 与其他连接方法相比,唯一不同的是提供程序或通过Visual Studio完成。 Provider I got was downloaded from PGfoundry http://pgfoundry.org/projects/oledb/ that's the only thing I could think would be the problem. 我得到的提供程序是从PGfoundry下载的,网址是http://pgfoundry.org/projects/oledb/ ,这是我唯一能想到的问题。 Any tips? 有小费吗?

Have you tried using Npgsql ? 您是否尝试过使用Npgsql? http://npgsql.projects.postgresql.org/ http://npgsql.projects.postgresql.org/

..
using Npgsql;
..

NpgsqlConnection con = new NpgsqlConnection("Server=192.168.0.64:5432;User ID=ourusername;password=ourpassword;Database=FRANK;timeout=1000");

also don't forget to configure the postgresql server files pg_hba.conf and postgresql.conf to accept your type of connection. 也不要忘记将postgresql服务器文件pg_hba.conf和postgresql.conf配置为接受您的连接类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM