GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Jul 23, 2014 9:42 am

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 
Offline

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: http://www.micahcarrick.com/files/dialo ... 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.

Code:

#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));
      exit(1);
   }
   /* send SQL query */
   if (mysql_query(conn, "show tables")) {
      fprintf(stderr, "%s\n", mysql_error(conn));
      exit(1);
   }
   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 */
   mysql_free_result(res);
   mysql_close(conn);
}

Can someone please help me?

Thanks,
Brian



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

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

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 - http://developer.gnome.org/glib/stable/glib-Spawning-Processes.html. So in your call back function, which is connect to a button click you just need to spawn an external application.

E.

_________________
E.


Top
 Profile  
 
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: Google [Bot] and 2 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