Re: Some questions..

On 03 Jan 2001 12:55:04 +0100, Francis Brosnan Blázquez wrote:
>  Hi, I am a developer of aspl-fact and I have some questions for you.


> 1) How can I make a connection, through gda, to the data-base and make a
> petition?
> Now, we are making this stuff  with something like this:
>     Gda_Connection *data_base_conection=NULL;
>     data_base_connection = gda_connection_new(gda_corba_get_orb());
>     gda_connection_set_provider(data_base_connection, "localhost");
>     gda_connection_open(data_base_connection, "DATABASE=data_base_name",
> user, password);
>     order = gda_command_new();
>     gda_command_set_connection(order, data_base_connection);
>     gda_command_set_text(order, SQL_string);
>     resultado = gda_command_execute(order, NULL, 0);
> but it does not work. The gda_corba_get_orb() function always returns a
> NULL pointer and our dear
> gda_connection_new () function doesn't like this.
> Simply, we don't know how to do a simple connection, can help us? Where
> can we find documentation
> or examples to do this?

have you called gda_init before calling gda_connection_new? If not, it
is clear that the ORB has not been initialized. What you must do is:

gda_init("my_program", NULL, argc, argv);
cnc = gda_connection_new(gda_corba_get_orb());

then, for the set_provider call, it's also wrong. What you must do is to
retrieve the information from the data source you want to use. This is
done with:

Gda_Dsn* dsn = gda_dsn_find_by_name("my_dsn");
if (dsn) {
   gda_connection_set_provider(cnc, GDA_DSN_PROVIDER(dsn));
   gda_connection_open(cnc, GDA_DSN_DSN(dsn), username, password);

You can also retrieve a list of available data sources with the function

You've got an example of all this in the libgda/testing/ directory

> 2) How must we use gnome-db header files?  If we put:
> #include <gnome-db/gnome-db.h>
> it doesn't work. Instead of this we are doing directly:
> #include <gnome-db/gnome-db-widget-name.h>
> Is it right ?
no, it's not. You should just "#include <gnome-db.h>", and, when compiling, use:

gcc -o my_program `gnomedb-config --cflags` file1.c file2.c

that is, you should use the gnomedb-config script to output all the
needed CFLAGS. The same applies for the LIBS:

gnomedb-config --libs


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