3

I am currently working with a task to connect with PostgreSQL and retrieve data from that DB to my .net application,I am using the code like

OdbcConnection con = new OdbcConnection("Driver={PostgreSQL };Server=localhost;Port=2012;Database=DataCenter;Uid=postgres;Pwd=post@123;");

but it is throwing an ODBException. Please suggest me a code.

1
  • 1
    What is the exact error message? Commented Jul 5, 2012 at 11:49

2 Answers 2

4

You may try that:

Driver={PostgreSQL};Server=IP address;Port=5432;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

You can definitely find more information on this website: http://www.connectionstrings.com/ And in your case particularely on this page: http://www.connectionstrings.com/postgre-sql#p51

If it does not solve your problem it is that the problem doesn't come from the connection string but your configuration of PostgreSQL. You might want to check that you're able to connect to the server using "psql" (for example) from your client computer.

Regards

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

Comments

0

For Ex:

 string connstring = String.Format("Server={0};Port={1};User Id={2};Password={3};Database={4};",
                           "localhost", "5432", "postgres", "metin", "ATALAY");

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.