0

sorry if this is too simple to be of help to most people.

This is the first time I have done anything remotely like this and it appears that my problem is too unadvanced to be covered in any documentation. I am trying to connect a c++ project in Visual Studio 2017 to a PostgreSQL database. Just to be clear, I know how to run pgAdmin/host databases, code in C++, and I think I could handle the npgsql syntax if I got it working. However, I've never used .NET (although 4.5 is on my computer).

Here's what I am doing:

I start an empty project for C++ in Visual Studio 2017.
I open nuget manager and search npgsql, but my project is pointing to native,v0.0 instead of a .NET framework.
So I target v4.5 in the .NET framework property, but that doesn't change anything.

Could someone please tell if what I am trying to do is possible?
Should I be using a different project other than empty project?
Does this need to be some kind of web application?

If it is possible I'd love any advice on how to do it.

1 Answer 1

1

If you are writing a native c++ program it is very unlikely you want to bring in a .net assembly. If you want to connect to a pg database I would suggest instead that you use the odbc driver (https://odbc.postgresql.org/) or perhaps there is some library available as part of PG, but using a .net assembly will require a great deal of unnecessary interop work.

1
  • That's correct - Npgsql is the .NET provider for PostgreSQL, meant to be used with .NET languages such as C#, F# or VB.NET. You're looking for a C++ driver, which would either be ODBC or PostgreSQL's native C access library, libpq. Dec 9, 2017 at 4:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.