GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Aug 29, 2016 7:52 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Connecting a button to pull data from MySQL - Please help
PostPosted: Thu Oct 27, 2011 1:30 pm 

Joined: Wed Oct 05, 2011 12:50 pm
Posts: 2
Hi all,

I am new to Glade and have Glade Interface Designer 2.12.1 installed on my CentOS5 machine. I have a C code which connects to a MySQL database and brings the table. I'm working on a tutorial which can be downloaded here: ... gs2.tar.gz and I would like to be able to press one of the buttons and by pressing that button, the C program gets called and the output would be shown on the screen.


#include <mysql.h>
#include <stdio.h>
main() {
   MYSQL *conn;
   MYSQL_RES *res;
   MYSQL_ROW row;
   char *server = "localhost";
   char *user = "root";
   char *password = "PASSWORD"; /* set me first */
   char *database = "mysql";
   conn = mysql_init(NULL);
   /* Connect to database */
   if (!mysql_real_connect(conn, server,
         user, password, database, 0, NULL, 0)) {
      fprintf(stderr, "%s\n", mysql_error(conn));
   /* send SQL query */
   if (mysql_query(conn, "show tables")) {
      fprintf(stderr, "%s\n", mysql_error(conn));
   res = mysql_use_result(conn);
   /* output table name */
   printf("MySQL Tables in mysql database:\n");
   while ((row = mysql_fetch_row(res)) != NULL)
      printf("%s \n", row[0]);
   /* close connection */

Can someone please help me?


 Post subject: Re: Connecting a button to pull data from MySQL - Please hel
PostPosted: Sat Oct 29, 2011 9:57 am 
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 1048
Location: UK

Glade interface designer 2.12.1 is now very old with version 3 introduced in August 2006 and the current version is 3.10.0, so I would really upgrade to a much more recent version.

You can spawn an external process by using one of the functions from the GLib library - So in your call back function, which is connect to a button click you just need to spawn an external application.



Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group