File: simple_8cpp-example.html

package info (click to toggle)
simpledb 1.5-1.4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze
  • size: 888 kB
  • ctags: 238
  • sloc: cpp: 529; makefile: 127; perl: 23; sh: 9
file content (36 lines) | stat: -rw-r--r-- 3,073 bytes parent folder | download
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&amp;nbsp;C++&amp;nbsp;ODBC&amp;nbsp;Database&amp;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&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;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] = {&amp;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 &lt;&lt; <span class="stringliteral">"Number: "</span> &lt;&lt; longCol &lt;&lt; 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&amp;type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>
</div>