<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to example</title><link>https://sourceforge.net/p/sqlite4pp/wiki/example/</link><description>Recent changes to example</description><atom:link href="https://sourceforge.net/p/sqlite4pp/wiki/example/feed" rel="self"/><language>en</language><lastBuildDate>Sun, 01 Jul 2012 10:14:39 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/sqlite4pp/wiki/example/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage example modified by Gavin</title><link>https://sourceforge.net/p/sqlite4pp/wiki/example/</link><description>
// a simple example to use SQLitePP
void simple_example()
{
	//define a connection
	SQLitePP::DBConnection conn;

	// connect to a database
	int rc = conn.connect("D:\\mytestdb.db");
	if (rc != 0) {
		std::cout &lt;&lt; conn.getErrorMessage() &lt;&lt; std::endl;
		return;
	}

	// define a command and set a command text
	SQLitePP::DBCommand cmd(&amp;conn);
	cmd.setCommandText("create table tbl_test(id integer not null, name text, contact text)");
	rc = cmd.execute(); // execute
	if (rc != 0) {
		std::cout &lt;&lt; conn.getErrorMessage() &lt;&lt; std::endl;
		return;
	}

	// insert data
	cmd.setCommandText("insert into tbl_test(id, name, contact) values(0, 'gavin', 'vxling@gmail.com')");
	rc = cmd.execute(); // execute
	if (rc != 0) {
		std::cout &lt;&lt; conn.getErrorMessage() &lt;&lt; std::endl;
		return;
	}

	// execute a query
	cmd.setCommandText("select * from tbl_test");
	rc = cmd.execute(); // execute
	if (rc != 0) {
		std::cout &lt;&lt; conn.getErrorMessage() &lt;&lt; std::endl;
		return;
	}

	// print all result
	while (cmd.fetchNext()) {
		std::cout &lt;&lt; cmd.field(0) &lt;&lt; ", " &lt;&lt; cmd.field(1) &lt;&lt; std::endl;
	}
}
</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gavin</dc:creator><pubDate>Sun, 01 Jul 2012 10:14:39 -0000</pubDate><guid>https://sourceforge.net96aead1b622c05f9d982417d4db21e8e7b288230</guid></item></channel></rss>