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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Code examples: GNOME Data Access 5 manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GNOME Data Access 5 manual">
<link rel="up" href="part_begin.html" title="Part I. Getting started">
<link rel="prev" href="installation-configuring.html" title="Configuring">
<link rel="next" href="connections.html" title="Connecting">
<meta name="generator" content="GTK-Doc V1.32 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="part_begin.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="installation-configuring.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="connections.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="getting_started"></a>Code examples</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="sect1"><a href="getting_started.html#initializing">Initializing</a></span></dt>
<dt><span class="sect1"><a href="connections.html">Connecting</a></span></dt>
<dt><span class="sect1"><a href="ch06s03.html">Executing queries</a></span></dt>
<dt><span class="sect1"><a href="data-model.html">Managing data models</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="data-model.html#data-model-table-access">Example using random access</a></span></dt>
<dt><span class="sect2"><a href="data-model.html#data-model-row-access">Example using an iterator</a></span></dt>
<dt><span class="sect2"><a href="data-model.html#data-model-free">Freeing data models</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="transactions.html">Managing transactions</a></span></dt>
<dt><span class="sect1"><a href="managing-errors.html">Managing connection's events and errors</a></span></dt>
<dt><span class="sect1"><a href="main_example.html">Full example</a></span></dt>
<dt><span class="sect1"><a href="ddl_example.html">DDL example</a></span></dt>
<dt><span class="sect1"><a href="blobs_example.html">Binary large objects (BLOBs) example</a></span></dt>
<dt><span class="sect1"><a href="other_examples.html">Other examples</a></span></dt>
</dl></div>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="initializing"></a>Initializing</h2></div></div></div>
<p>
First of all you have to initialise the gda library, i.e. to call the
<a class="link" href="libgda-5.0-Libgda-Initialization.html#gda-init" title="gda_init ()">gda_init ()</a> function, for example:
</p>
<pre class="programlisting">
gda_init ();
</pre>
<p>
After initializing you can work as usual or make <span class="application">Libgda</span>
</p>
<p>For example a basic program would look like:
</p>
<pre class="programlisting">
void
do_stuff ()
{
GdaConnection *connection;
/* open a connection */
g_print ("CONNECTING\n");
connection = gda_connection_open_from_dsn ("calvaris", NULL,
GDA_CONNECTION_OPTIONS_READ_ONLY, NULL);
g_print ("CONNECTED\n");
/* use the connection */
execute_some_queries (connection);
/* close the connection */
g_object_unref (G_OBJECT (connection));
}
int
main (int argc, char **argv)
{
g_print ("STARTING\n");
gda_init ();
do_stuff();
g_print("ENDING\n");
}
</pre>
<p>
</p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.32</div>
</body>
</html>
|