简体   繁体   中英

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. 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. However when I try to connect using Ole DB through Visual Studio and the connection string something like:

"Provider=PostgresSQL OLE DB Provider;Server=192.168.0.64:5432;location=FRANK;User ID=ourusername;password=ourpassword;timeout=1000;"

I got this from connectionstrings.com and they've never let me down before. 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

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. Provider I got was downloaded from PGfoundry http://pgfoundry.org/projects/oledb/ that's the only thing I could think would be the problem. Any tips?

Have you tried using Npgsql ? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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