// Collection of code snippets by Arne VajhÃ¸j 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
#include <iostream>

using namespace std;

#include "mysqlobj.h"

int main()
{
    //
    // åben connection til:
    //   database = "Test"
    //   server = "localhost" (default)
    //   username = "root" (default)
    //   password = "" (default)
    //   port = 3306 (default)
    //
    Connection con("Test");
    if(!con.IsConnected())
    {
        cerr << con.GetError() << endl;
        exit(1);
    }
    // udfør query
    ResultSet rs = con.ExecuteQuery("SELECT * FROM t1");
    // print resultat af query
    while (rs.Next()) {
        for (int i=0; i<rs.GetNoFields(); i++) {
            cout << " " << (!rs.IsNull(i) ? rs.Get(i) : "NULL");
        }
        cout << endl;
    }
    return 0;
}
