views:

71

answers:

2

Hi,

I'm trying to make my first simple program that uses databases. I decided to use SQLite as it allows to store database into a single file. I think I have managed to do a database with SQLite Database Browser, but I have no idea how I could read that data in a C/C++ program. So can someone help me to get started or point me some tutorial to SQLite.

Thank you in advance :)

-zaplec

+2  A: 

http://www.sqlite.org/quickstart.html

Lauri
Thanks. I didn't notice that QuickStart tutorial while browsing the sqlite sites myself. Looks exactly what I need: Simple instructions how get started with SQLite and not anything advanced jargon yet :)
zaplec
+1  A: 

How about the 'An Introduction to Sqlite C/C++ Interface', and there is a whole C++ example here on codeplex

This is bits of the more full sample,

#include "CppSQLite.h"
#include <ctime>
#include <iostream>
using namespace std;
const char* gszFile = "C:\\test.db";

int main(int argc, char** argv)
{
    try
    {
        int i, fld;
        time_t tmStart, tmEnd;
        CppSQLiteDB db;

        cout << "SQLite Version: " << db.SQLiteVersion() << endl;

        db.open(gszFile);
        cout << db.execScalar("select count(*) from emp;") 
               << " rows in emp table in ";
        db.Close();
    }
    catch (CppSQLiteException& e)
    {
        cerr << e.errorCode() << ":" << e.errorMessage() << endl;
    }
}
Preet Sangha