Re: [gnome-db] Need Help for libgdata in GTK programing



Hi!

The gda_data_model_dump_as_string() creates a string which contains the whole datamodel's values(it's mainly intended for debugging), basically gda_data_modeil_dump() is just a wrapper around that function.

You should use:
const GValue *value;
value = gda_data_model_get_value_at (model, 0, 0, &error);
if (! value)

gchar *str;
str = gda_value_stringify (value)



2016-01-31 18:08 GMT+01:00 Nihsant Chawre <nishant chawre gmail com>:
Hello Sir,
I am fresher in development for linux.

I know this is very basic and silly question, but i stuck here.

I am trying to set the text of lable with the value whatever is returned by
database select query, i.e. label should be set as "vedesa1" but is getting
set as "shopid ───────vedesa1(1 row)"

i think i need to use "gda_data_model_get_value_at" function to get the
sting "vedes1"  , but somehow with lack of experience i am not ablw to use
it, cam someone please help me out



* Table shop contailns single entry as

shopid
───────
vedesa1




* command line used to compile the code is
gcc `pkg-config --cflags gtk+-3.0`  -o SAMPLE SAMPLE.c `pkg-config --libs
gtk+-3.0` `pkg-config --cflags --libs libgda-5.0`


*  existing code  snipet is as follows

GdaDataModel *data_model0 , *data_model1;
GdaSqlParser *parser;
GdaStatement *stmt0 , *stmt1;
gchar *sql1 = "SELECT shopid  FROM shop";
GError *error = NULL;
GValue *value1;

parser = g_object_get_data (G_OBJECT (cnc), "parser");

stmt1 = gda_sql_parser_parse_string (parser, sql1, NULL, NULL);

data_model1 = gda_connection_statement_execute_select (cnc, stmt1, NULL,
&error);
g_object_unref (stmt1);
if (!data_model1)
                g_error ("Could not get the contents of the 'products'
table: %s\n",error && error->message ? error->message : "No detail");

        g_print("above gda_data_model_dump \n");
        gda_data_model_dump (data_model1, stdout);


        g_print ("\nin g_print %s", gda_data_model_dump_as_string(data_model1));


(GTK_ENTRY(entry1),gda_data_model_dump_as_string(data_model1));
        gtk_entry_set_text (GTK_ENTRY(entry1),value1);

_______________________________________________
gnome-db-list mailing list
gnome-db-list gnome org
https://mail.gnome.org/mailman/listinfo/gnome-db-list



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