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

Olukayode Oluwole
Olukayode Oluwole used Ask the Experts™
on
I have a c#  application which needs to write into sqlserver  and postgresql  databases.

I  use Dapper  ORM

I have been able to specify my connection string   for sqlserver  and it works

Now i am trying to specify  the equivalent  for  PostgreSQL  and I am getting the

Error   " OLE DB Provider  not Specified in the Connection String "

I have tried the following 3  providers

providerName="Npgsql2" />
providerName="Npgsql" />
providerName="SQLOLEDB" />

with same error message

Whats should be my provider string  for a c# application  connection to a

PostgreSQL database  using Dapper

Please Note that  I have Dapper  and   Npgsql installed in my application using Nuget

Attached please find error screen using the debugger and my connection string PostgreSQL

I will be grateful for an assistance

O.A.  Oluwole
OLE-DB-PROVIDER--24-09-2018.docx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Use one of the strings published here: https://www.connectionstrings.com/postgresql/
It seems Npgsql does not need providerName. If Npgsql does not work for you then you may try different method (ODBC, etc.)
Database Analyst
Commented:
The error from your attachment related to OLE DB connection says pretty clear that "no OLE DB provider was specified in the connection string so you would have to change it as described here: https://www.connectionstrings.com/pgoledb/
in your case this would be like like the string below:

Provider=PostgreSQL OLE DB Provider;Data Source=localhost:5432;location=Tournaments;User ID=myUsername;password=myPassword;

If postgres is running on your local Windows computer the npgsql string should be like described here https://www.connectionstrings.com/npgsql/:

Server=localhost;Port=5432;Database=Tournaments;Integrated Security=true;
Olukayode OluwoleSystems Analyst

Author

Commented:
Tried your suggestion but still got the same error

See  attached  word document

What do you suggest i try next

Thanks

Olukay
OLE-DB-PROVIDER--24-09-2018.docx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial