C++ Database Connection - c++

I need to connect to a database with c++, I have tried to use mySql++, mySql connector, and a few others however I am unable to get them running, I've tried the tutorials but I can't seem to get them right. VS doesn't see the files that I try to include.
Anyways, Is there a somewhat easy way to connect to a database using c++ without needing to download a ton of files or api's. and if so could you please provide a link to a tutorial, ive tried using ODBC, however I don't think ive been doing it right as it shows a ton of errors in my code.
any help would be appreciated,
Thanks

How about OTL. It is just a header file so far away from tons of files. And all you need is the libraries depending on the DB you want to connect to.

ODBC is a little bare metal - surely there are some more accessable ADO classes (you might need MDAC)?

First, you have to know what kind of database you have to connect to. It does matter, as you won't use the same API to connect to a MySQL database, or to a SQLite one, or Oracle, or Postgres, or SQL Server ...
Then, have a look at the library that allows acces to the database. And make sure that the database is actually present!

C++ Standard doesn't has native database support. You cannot connect to a database using C++ without database/platform specific libraries. Such as this or this one, if you want to connect to MySQL server.

Related

How to use SQLite database from one platform(iOS) to another(Windows)

I don't know its a valid question or not.
I am working on one MFC/C++ application where
I want to use SQLite database from iOS application in my windows application.
My iOS database is encrypted using command sqlite_key.
While I am trying it for my windows application for the same database
It throws an exception for any operation on the database.
While Searching on Google I am not able to get right track for this.
Can anyone tell me is it possible?
And if yes please help me on this.
If your plan is to "export" it, i.e you want to reuse the data inserted by your ios application into your windows one, then you simply need to locate on your iphone the sqlite database file (sqlite store everything in one single location) and copy it on your computer, and tell your windows software the location of this file.
If your is to "share" the database, i.e both should be able to modify it in "realtime", then you will have to roll something on your own, as Sqlite3 does not provide any network support, it's just a library to read and write data in a file, in a SQL way.

C++ Database API's - DTL

I'm looking for a C++ API that is able to connect to different types of databases all in one; mainly MySQL, oracle and SQL Server and I believe I have found one with "DTL" ( http://dtemplatelib.sourceforge.net/ )
However, I'm struggling to connect my database on localhost. Has anyone used this before and could shed some more light on it other than what their site does with
DBConnection::GetDefaultConnection().Connect("UID=example;PWD=example;DSN=example;");
though I guess what to put in uid and pwd, I'm not sure what it's expecting in 'dsn', are there any REAL examples or have you guys used it before and could help.
This is an ODBC library, so DSN is the ODBC data source name. On Windows, these can be configured under Administrative Tools->Data Sources.
As #Dark Falcon said, the "DSN" refers to an "ODBC data source". What you get is an extra level of indirection like this:
On Windows, you normally create the ODBC data source with the "Data Sources (ODBC)" control panel, which is normally in the "Administrative Tools".
In any case, this separates the configuration/deployment "stuff" from the code. For example, if you want to use your code with a test database during development, then with the "live" database when you deploy it, you can do that without making any changes to your code, and even without changing the connection string. Instead, you change the data source to refer to production server instead of the test server.

Is there any way to connect to oracle db using simple c++ not vc++ or proc

I am struggling to connect to oracle db using GNU C++.Is there any library which I have to install to connect to oracle db using simple c++ (oops).
Please provide me some sample code as well, this is new for me. Appreciate your help.
I asked a similar question before but forgot to mention that I am not using vc++ and proc.
You would need the oracle C++ libraries (OCCI) from oracle. You can find them here:
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
Google "Oracle OCCI tutorial" and you should find pretty much everything you need.
Check out SOCI. It supports several database backends, including Oracle, MySQL, Postgre, ODBC, etc. Using this library would make it easier for you to migrate your application to a different DB, if necessary.
There's a code sample here. And several more peppered in the documentation.

C++ Windows Form Application Mysql Connection

I can't seem to figure out how to connect to mysql in my windows form application. I've installed all the proper libraries and have included them, thats not the issue. The issue is I can't find a tutorial on connecting to mysql. I've found some one console applications, tried them, but yet for some reason they do not work. I just need to be sent into the right direction, thanks.
I don't know what library you're using, but I recommend MySQL++. It's simple, has a great manual and lot of examples.

MS Access backend for django

I've been working on a modification of the django-pyodbc package so that it could be used with MS Access.
I need this for a legacy database we are tied to at my organization, and have been doing a rather hacky job specific to my situation, but have also been making useful, generalizable progress in terms of adapting SQL syntax for MS Access.
My question is, is this a project that anyone else in the world is interested in? should I clean up my code and try to fully generalize it, or is everyone else in the world able to solve their MS Access problems by moving to SQL server?
I would move the data to SQL Server if that is an option.
If moving the data is not an option and if my Django app is already connecting to SQL Server, I might just create a linked server on SQL Server and go through SQL Server instead.