We help IT Professionals succeed at work.

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

294 Views
Last Modified: 2018-09-10
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

Notes:

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

Thanks

Oluwole
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019

Commented:
Not a Postgres Expert but connect strings are pretty available on the Web:
https://www.connectionstrings.com/postgresql/
Olukayode OluwoleSystems Analyst

Author

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

Thanks

Oluwole
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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.
Olukayode OluwoleSystems Analyst

Author

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)

Regards

O.A.  Oluwole
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
Two questions:  1. Do you have the PostgreSQL driver installed on that system?  2. What is the error message you are getting?
Olukayode OluwoleSystems Analyst

Author

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=127.0.0.1;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

Thanks

O.A.  Oluwole
Fixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions