El vie, 01-11-2002 a las 20:16, Rodrigo Moya escribió:
> ok, the problem is that gda_client_open_connection only returns a valid
> GdaConnection if it can connect to the database. So, first of all, you
> should check the return value of that function:
>
> connection = gda_client_open_connection (client, "ds_prueba", NULL,
> NULL);
> if (GDA_IS_CONNECTION (connection))
> g_print ("CONNECTED\n");
> else
> g_error ("could not open connection");
>
> as a better way, you can connect (g_signal_connect) to the "error" signal on the
> GdaClient object, and the callback you set up for the signal will be called
> with error information if there is an error. So:
>
> client = gda_client_new ();
> g_signal_connect (G_OBJECT (client), "error", client_error_cb, NULL);
> ...
>
> void
> client_error_cb (GdaClient *client, GdaConnection *cnc, GList *errors, gpointer data)
> {
> GList *l;
>
> for (l = errors; l != NULL; l = l->next) {
> GdaError *err = l->data;
> g_print ("ERROR: %s\n", gda_error_get_description (err));
> }
> }
>
> This will show up the error messages from the database server, so that might give you
> a hint of what is failing.
>
> But anyway, just guessing, if you connect locally (DB server in the same machine),
> the DSN should be:
>
> gda_config_save_data_source ("ds_prueba", "MySQL", "DATABASE=mysql;UNIX_SOCKET=/var/run/mysqld/mysqld.sock",
> "Test access", "root", NULL);
>
> also, instead of creating a data source, you can just call
> gda_client_open_connection_from_string.
>
> cheers
Hi.
Thanks! It is working now. I will keep practising :-)
Though, I found two strange things. The first function (show_table)
defined in the examples, only showed the name of the first column. The
sencond (show_table2), printed out an 'Segment fault' :-?
For the first one, I have written:
void show_table (GdaDataModel * dm)
{
gint row_id;
gint column_id;
GdaValue *value;
for (column_id = 0; column_id < gda_data_model_get_n_columns
(dm); column_id++)
{
g_print ("%s\t", gda_data_model_get_column_title (dm,
column_id));
}
g_print ("\n\n");
for (row_id = 0; row_id < gda_data_model_get_n_rows (dm);
row_id++)
{
for (column_id = 0; column_id <
gda_data_model_get_n_columns (dm); column_id++)
{
value = (GdaValue *) gda_data_model_get_value_at
(dm, column_id, row_id);
g_print ("%s\t", gda_value_stringify (value));
}
g_print ("\n");
}
}
I know it is nearly the same, but it is a little confusing at first; I
kept wondering why the other column names weren't being shown.
At last. ¿Is it possible to get the manual in a printable format?
Thanks. Bye.
--
___________________________________________________________
Ricardo Cervera Navarro (lical)
Usuario registrado de Linux #254225
Claves GNUPG: http://ns.zonasiete.org/~ricardo/lical.asc
ricardo AT zonasiete DOT org
ricardo.cervera AT hispalinux DOT es
"May the SOURCE be with you"
___________________________________________________________
Attachment:
signature.asc
Description: Esta parte del mensaje esta firmada digitalmente