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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Simple&nbsp;C++&nbsp;ODBC&nbsp;Database&nbsp;API: simple.cpp</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.2 -->
<div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="pages.html">Related Pages</a> | <a class="qindex" href="examples.html">Examples</a></div>
<h1>simple.cpp</h1>This is a simple example of how to use the Simple Database API. The test consists of the following steps:<p>
<ul>
<li>Connect to the data source. </li>
<li>Create a query object from the database. </li>
<li>Create the columns that will be bound to the query. </li>
<li>Bind the columns to the query. </li>
<li>Execute the query. </li>
<li>Fetch the result of the query.</li>
</ul>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include "SimpleDB/SimpleDB.h"</span>
<span class="keywordtype">int</span> main() {
<a name="_a22"></a><a class="code" href="classSimpleDB_1_1Database.html">SimpleDB::Database</a> db = <a class="code" href="classSimpleDB_1_1Database.html">SimpleDB::Database</a>(<span class="stringliteral">"eminence"</span>);
<a name="_a23"></a><a class="code" href="classSimpleDB_1_1Query.html">SimpleDB::Query</a> query = db.<a name="a24"></a><a class="code" href="classSimpleDB_1_1Database.html#a1">newQuery</a>();
<a name="_a25"></a><a class="code" href="classSimpleDB_1_1LongColumn.html">SimpleDB::LongColumn</a> longCol = <a class="code" href="classSimpleDB_1_1LongColumn.html">SimpleDB::LongColumn</a>();
<a name="_a26"></a><a class="code" href="classSimpleDB_1_1Column.html">SimpleDB::Column</a> * columns[1] = {&longCol};
query.<a name="a27"></a><a class="code" href="classSimpleDB_1_1Query.html#a2">bind</a>(columns, 1);
query.<a name="a28"></a><a class="code" href="classSimpleDB_1_1Query.html#a3">execute</a>(<span class="stringliteral">"SELECT count(contact_number) FROM contacts"</span>);
query.<a name="a29"></a><a class="code" href="classSimpleDB_1_1Query.html#a4">fetchRow</a>();
std::cout << <span class="stringliteral">"Number: "</span> << longCol << std::endl;
<span class="keywordflow">return</span> 0;
}
</pre></div> <hr>
<div align="right"><small>
Copyright (C) 2005 <a target="top" href="http://www.eminence.com.au">Eminence Technology Pty Ltd</a>.<br>
Documentation pages generated by doxygen.</small><br>
<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=129109&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>
</div>
|