1

So I have the following connection string which is causing me issues. I am attempting to write an application which is capable of being database agnostic (difficult but not impossible) and I have come to testing it on PostgreSQL however I cannot seem to get an OLE connection to work with it. From what I have seen it is entirely possible.

I got everything working using a specific class for PostgreSQL but this used the Npgsql types rather than generic OLE types.

E.g. private NpgsqlCommand m_postgreSQLDatabaseCommand;

Instead of private OleDbCommand m_oleDatabaseCommand;

This is not acceptable in my circumstances.

I tried simply changing the connection string to use the Npgsql provider but I am not sure if I am using it correctly. I get the error below:

Connection String:

<add name="ApplicationPostgresDefault" 
    connectionString="Server=127.0.0.1;Port=5432;
    Database=myDatabase;
    User Id=myUser;
    Password=myPass; 
    Provider=Npgsql"
/>

Error:

The 'Npgsql' provider is not registered on the local machine.

What can be done to solve this?

If I get the provider in there correctly will I be able to communicate with PostgreSQL as I was with Npgsql objects?

2 Answers 2

2

The local machine doesn't have the provider installed.

I would suggest using a native client rather than OleDb anyway:

http://npgsql.projects.postgresql.org/

http://connectionstrings.com/Providers/npgsql

that's your choose

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

4 Comments

Well the reason for using Ole is that I will not be aware of the platform and as such cannot hard code anything. The need for a universal method of connection is paramount. The only prior knowledge of database platform will be via a web.config or app.config entry. This means I could not for example hard code different versions of my code for each platform. My software must be unaware of the database platform and able to run on any (well known) format. The provider seems the only option. Thanks
Also how do you install the provider? There is no exe within my downloaded npgsql folder.
I have the provider in the form of the three dlls. npgsql.dll mono.security.dll and policy.2.0.npgsql.dll. The error says npgsql is not registered on the machine. How can I fix that specific problem? I would prefer not to have to add anything to the GAC
I followed the link and added to GAC (although I didnt want to do that) and it is still saying it is not registered. I want to keep the application self contained but I am not finding answers to this one
0

Are you missing a ; after Npgsql ?

2 Comments

Tried adding it on and as I suspected this isn't the problem. It may well have been had it occurred earlier in the string.
I guess it's not that importent when it's last in the connectionstring. I think Maziar can help.

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.