4

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?

2
  • Check if you DB is called really "FRANK" (all uppercase)! More info why this is important here - "4.1.1. Identifiers and Key Words". Commented Jul 17, 2012 at 18:47
  • @MilenA.Radev Thanks for the response, yes it really is all uppercase. I ran the code again changing the location to "frank" just in case. I guess I'll also mention it can't find other databases on that server, including the default postgres database, so the problem isn't solely that database. Commented Jul 23, 2012 at 16:37

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Npgsql is an ADO.Net provider, not Oledb. A commercial Oledb provider can be found here [pgoledb.com/… (Product of Intellisoft LLC)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.