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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Beginning</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GNOME Data Access manual">
<link rel="up" href="index.html" title="GNOME Data Access manual">
<link rel="prev" href="installation-configuring.html" title="Configuring">
<link rel="next" href="connections.html" title="Connecting">
<meta name="generator" content="GTK-Doc V1.10 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="introduction.html" title="Introduction">
<link rel="chapter" href="architecture.html" title="libgda architecture">
<link rel="chapter" href="installation.html" title="Installation">
<link rel="chapter" href="connecting.html" title="Beginning">
<link rel="chapter" href="processing-queries.html" title="Processing queries">
<link rel="chapter" href="ch06.html" title="Transactions and batch processes">
<link rel="chapter" href="managing-errors.html" title="Managing errors">
<link rel="chapter" href="main_example.html" title="Full example">
<link rel="chapter" href="migration.html" title="Some formulae for migration from old version">
<link rel="chapter" href="libgda-api.html" title="Client API Reference">
<link rel="chapter" href="libgda-providers.html" title="GDA Providers">
<link rel="chapter" href="libgda-xql.html" title="XML Queries">
<link rel="chapter" href="libgda-reports.html" title="GDA Report Engine">
<link rel="appendix" href="fdl.html" title="Appendix A. GNU Free Documentation License">
</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="2"><tr valign="middle">
<td><a accesskey="p" href="installation-configuring.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td> </td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GNOME Data Access manual</th>
<td><a accesskey="n" href="connections.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter" lang="en">
<div class="titlepage"><div><div><h2 class="title">
<a name="connecting"></a>Beginning</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="sect1"><a href="connecting.html#initializing">Initialising</a></span></dt>
<dt><span class="sect1"><a href="connections.html">Connecting</a></span></dt>
</dl></div>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="initializing"></a>Initialising</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-libgda.html#gda-init" title="gda_init ()"><span class="emphasis"><em>gda_init ()</em></span></a> function.
</p>
<pre class="programlisting">
gda_init ("TestGDA", "0.1", argc, argv);
</pre>
<p>
After initialising you can work as usual or make a function with the whole
stuff, calling <a class="link" href="libgda-libgda.html#gda-main-run" title="gda_main_run ()">gda_main_run()</a>. Note that
if you use this way you will need to call <a class="link" href="libgda-libgda.html#gda-main-quit" title="gda_main_quit ()">gda_main_quit()</a> in order to finish the program.
</p>
<pre class="programlisting">
void
do_stuff ()
{
GdaClient *client;
GdaConnection *connection;
list_providers ();
list_datasources ();
client = gda_client_new ();
g_print ("CONNECTING\n");
connection = gda_client_open_connection (client, "calvaris", NULL, NULL,
GDA_CONNECTION_OPTIONS_READ_ONLY);
g_print ("CONNECTED\n");
execute_some_queries (connection);
g_print ("ERRORS PROVED!\n");
process_accounts(connection);
gda_client_close_all_connections (client);
g_object_unref(G_OBJECT(client));
play_with_parameters();
gda_main_quit();
}
int
main (int argc, char **argv)
{
g_print ("STARTING\n");
gda_init ("TestGDA", "0.1", argc, argv);
save_ds ();
gda_main_run ((GdaInitFunc) do_stuff, (gpointer) NULL);
/* do_stuff(); */
g_print("ENDING\n");
}
</pre>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.10</div>
</body>
</html>
|