rupert wrote: > Great idea, the documentation is a bit complicated for me, so are > there more howtos for this(without line numbers) and with small examples? > It took me a lot to get started with it, specially because the api changed just when i started... je.
> Also im not sure if I should use gnomedb or libgda to get my data out > of the DB. You have to use both, libgda handles the database system and gnomedb gives you widgets for showing/editing the data. > Can i handle a database in a xml file like a normal DB like mysql? > This would really remove the need to install mysql, if I ever make my > project public, > which I would like because there is nothing like that for linux atm. I dont know much about databases, ive just made a program wich uses one. What i know is that libgda has a client wich uses a file for storing the database and you can use regular sql with it. I alse saw something about XML source, but dont knkow, sorry. This is an example (from my app) wich (with all existing and created with glade) shows a database on a grid: void on_ticket_view_show (GtkWidget *widget, gpointer user_data) { GdaCommand *cmd; GdaDataModel *recset; GnomeDbGrid *grid; gchar *str; grid=GNOME_DB_GRID(lookup_widget(widget,"ticket_view_dbg")); /* Clear its content first */ if ((recset=gnome_db_grid_get_model(grid))!=NULL) g_object_unref(G_OBJECT(recset)); str=g_strdup_printf( "\"select producto as codigo ,(select nombre from productos where id=producto) as descripcion,cantidad,(select publico from productos where id=producto) as p_uni,total from detalles where codigo=%d\"", boa_fe.id ); cmd = gda_command_new ( str, GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS); recset = gda_connection_execute_single_command (boa_fe.conn, cmd, NULL); g_free(str); gnome_db_grid_set_model (grid,recset); gnome_db_grid_set_selection_mode(grid,GTK_SELECTION_SINGLE); gda_command_free (cmd); g_object_unref (G_OBJECT (recset)); gtk_widget_grab_focus(lookup_widget(widget,"ticket_view_dbg")); } > > greets > > On 3/19/06, *Juan Pablo* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > You should use gnomedb. > > Saludos, Juan. > > rupert wrote: > > >Hello, > > > >im trying to create an application that uses a mysql database to > get its > >information, > >first a treeview is created from the information stored in one > column, than > >when I select a row some more information should be displayed > >as GTK Labels and a picture is shown for each row. > >I have the whole thing working, with a simple treeview generated > from data > >stored in a textfile. > > > >How should I handle the database connection, i thought i can get > the whole > >data once and put it into different varibles, > >but i havent found a way to extract the data from the rows. > >right now im trying to give the select Title to my label display > function > >and do a query with "Select Info FROM table WHERE Title = "title"", > >but i always get Segmentation faults as soon as i try to use a > WHERE or > >something else in may query. > >In the top of my main() i have the connection and i just give the > *my to the > >functions where the queries are defined. > > > >Please give me some tips how I can solve this problem the best > way, I think > >having a global structe which i can access via if() or something > would be > >better than doing a SELECT everytime i need some information. > > > > > > >//__________Datenbank___________________________________________________________________ > > > > MYSQL *my; > > > > my = mysql_init(NULL); > > > > if(my == NULL) { > > > > fprintf(stderr, " Initialisierung fehlgeschlagen\n"); > > return EXIT_SUCCESS; > > } > > /* Mit dem Server verbinden */ > > if( mysql_real_connect (my, NULL, "root", NULL, "shdf", 0, > NULL, 0) == > >NULL) > > { > > fprintf (stderr, "Fehler mysql_real_connect():" > > "%u (%s)\n",mysql_errno (my), mysql_error (my)); > > } > > else > > printf("Erfolgreich mit dem MySQL-Server verbunden\n"); > > > > /* Hier befindet sich der Code für die Arbeit mit MySQL */ > > mysql_select_db(my, "shdf"); > > >//_____________________________________________________________________________ > > > > > >//the function that fills the treeview list > > > >void make_list(GtkListStore *liste, GtkTreeIter iter, MYSQL *my){ > > > > MYSQL_ROW row; > > MYSQL_RES *result; > > MYSQL_FIELD *field; > > > > gint i=0; > > > > char *query; > > query = "SELECT Title FROM table WHERE nr < 107" ; > > > > mysql_real_query(my, query, strlen(query)); > > result = mysql_store_result(my); > > > > while ((row = mysql_fetch_row (result)) != NULL) > > { > > mysql_field_seek (result, 0); > > > > for (i = 0; i < mysql_num_fields(result); i++) > > { > > gtk_list_store_append(liste, &iter); > > gtk_list_store_set(liste, &iter, STRING_SPALTE, > row[i],-1); > > } > > > > } > > > > free(query); > > > >greetings > >_______________________________________________ > >gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org <mailto:gtk-app-devel-list@gnome.org> > >http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > > > > > > > > > ___________________________________________________________ > 1GB gratis, Antivirus y Antispam > Correo Yahoo!, el mejor correo web del mundo > http://correo.yahoo.com.ar > > > ___________________________________________________________ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list