C++ and SQL

How to link a c++ program to MySQL DB.
I want to get the input in the program and store it in the DB.Please help.
This http://www.sqlapi.com/ is probably the easiest to use as it doesn't require linking(iirc).
The first example from the site...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>  // for printf
#include <SQLAPI.h> // main SQLAPI++ header

int main(int argc, char* argv[])
{
    SAConnection con; // create connection object
    
    try
    {
        // connect to database
        // in this example it is Oracle,
        // but can also be Sybase, Informix, DB2
        // SQLServer, InterBase, SQLBase and ODBC
        con.Connect(
            "test",     // database name
            "tester",   // user name
            "tester",   // password
            SA_Oracle_Client);

        printf("We are connected!\n");

        // Disconnect is optional
        // autodisconnect will ocur in destructor if needed
        con.Disconnect();

        printf("We are disconnected!\n");
    }
    catch(SAException &x)
    {
        // SAConnection::Rollback()
        // can also throw an exception
        // (if a network error for example),
        // we will be ready
        try
        {
            // on error rollback changes
            con.Rollback();
        }
        catch(SAException &)
        {
        }
        // print error message
        printf("%s\n", (const char*)x.ErrText());
    }
    
    return 0;
}
Is there any tuts for begginers?
I learned the MySQL C API when I was learning PHP. Function names are exactly the same for both C and PHP. Here's a tutorial on MySQL C API http://zetcode.com/tutorials/mysqlcapitutorial/

There is also a MySQL C++ API which I believe is compatible with Java's JDBC API.

Good luck!!
I don't understand how to use C in C++. Help please?
Topic archived. No new replies allowed.