Re: [gnome-db] A small question.

On Fri, 2002-11-01 at 20:00, Ricardo Cervera Navarro wrote:
> El vie, 01-11-2002 a las 19:35, Rodrigo Moya escribió:
> > On Fri, 2002-11-01 at 19:27, Ricardo Cervera Navarro wrote:
> > > Hi.
> > > 
> > > 	I wonder if this is the correct place to ask this. If not, sorry.
> > > 
> > > 	I am starting to use libgda (running the code of the examples in the
> > > manual) and having a small problem. My little programs compile cleanly
> > > but when I run them and try to do a query, I get this:
> > > 
> > > 
> > > 
> > > ** (TestGDA:1642): CRITICAL **: file gda-connection.c: line 642
> > > (gda_connection_execute_command): assertion `GDA_IS_CONNECTION (cnc)'
> > > failed
> > > 
> > > 
> > this error is because you're passing an incorrect GdaConnection to that
> > function. Could you show us the code of your program?
> 	Sure. It is based on the examples in the manual:
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,
	if (GDA_IS_CONNECTION (connection))
		g_print ("CONNECTED\n");
		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);

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]