What would be the PostgreSQL database connection string equivalent for a known sqlserver connection string

I have a C# application that needs to connect to sqlserver and postgresql

I have been able to connect it to sqlserver and it works and the connection string is shown below

<add name="Tournaments" connectionString="Server=CHRISTINESPC;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>

I have tried a number of options for postgresql without success

Can anybody kindly help to specify what  the postgresql  connection string equivalent is


CHRISTINESPC is my servername as displayed in sqlserver  management studio thou I am open to using an IP address
Tournaments my Database name in both sqlserver and postgresql databases


Olukayode OluwoleSystems AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Not a Postgres Expert but connect strings are pretty available on the Web:
Olukayode OluwoleSystems AnalystAuthor Commented:
I have actually tried the options i saw from that web site without success

I believe some one who has tried connecting  c#  to postgresql would

find this straight forward


David FavorLinux/LXD/WordPress/Hosting SavantCommented:
You asked...

What would be the PostgreSQL database connection string equivalent  for a known sqlserver connection string which seems odd.

SQL Server + PostgreSQL are two different products... Both are databases... so if this is your question, you can't...

If by known sqlserver connection string you really mean known PostgreSQL connection string... you state you have a working connection string already...

State the problem you're trying to solve coming up with a different connection string.
Price Your IT Services for Profit

Managed service contracts are great - when they're making you money. Yes, you’re getting paid monthly, but is it actually profitable? Learn to calculate your hourly overhead burden so you can master your IT services pricing strategy.

Olukayode OluwoleSystems AnalystAuthor Commented:
Please read my very first post.

The question is how to get the postgresql connection string for a C# application

The example i gave was for connection of a C# application to sqlserver from my application

The issue is that i need the 2 connection strings (and currently only have 1 working)


O.A.  Oluwole
Dave BaldwinFixer of ProblemsCommented:
Two questions:  1. Do you have the PostgreSQL driver installed on that system?  2. What is the error message you are getting?
Olukayode OluwoleSystems AnalystAuthor Commented:
1. YES  I have postgresql 9.5 installed on my laptop and connects to it with a visual basic. application

2. The Connection string for  sqlserver and postgresql from my C# application  are as shown below

for sqlserver:

<add name="Tournaments" connectionString="Server=CHRISTINESPC;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>

with sqlserver connection my application runs

for postgresql:

<add name="Tournaments" connectionString="Server=;Port=5432;Database=Tournaments;Integrated Security=true;
" providerName="System.Data.SqlClient"/>

With postgresql i get the error  below:

System.ArgumentException: 'Keyword not supported: 'port'.'

Please note that in both case i use Dapper to effect connection.

What do you suggest i try


O.A.  Oluwole
Dave BaldwinFixer of ProblemsCommented:
providerName="System.Data.SqlClient" is for MS SQL Server and Not PostGreSQL.  Info on the psqlODBC - PostgreSQL ODBC driver is on this page:  https://odbc.postgresql.org/   Connection strings to use with that driver can be found here:  https://www.connectionstrings.com/postgresql-odbc-driver-psqlodbc/  Dapper won't help if you don't have the correct drivers and give it the correct information to work with.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.