help on gtk with mysql.

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

 



Hi I am sameer.
 
           I am using Gtk and Mysql in that i am using combobox for insertion into the database.
There i am getting error gtkcombo have no property named text.
are there any solutions for this.
I am also using spin buttons for inserting data.for this also the same error i am getting.
 
I am sending my code which i have done also with error.
 
please help me.
 

#include <gtk/gtk.h>
#include <glib.h>
#include <stdio.h>
#include <mysql/mysql.h>
#include <string.h>

 char *p,*q;
 MYSQL mysql;
 GtkWidget *entry1,*entry2;
 GtkWidget *box1;
 GtkWidget *window;
 GtkWidget *button;
 GtkWidget *combo;
 GList *items = NULL;

gint destroyapp (GtkWidget *widget, gpointer gdata)
{
  gtk_main_quit();
  return (FALSE);
}
doSQL(MYSQL *conn,char *command)
{
  printf("%s\n",command);
  mysql_query(conn,command);
  printf("result: %s\n",mysql_error(conn));
}
a()
{
  MYSQL *conn;
  conn=mysql_init(NULL);
  if(mysql_real_connect(conn,"localhost",NULL,NULL,"mysql",0,NULL,0))
  {
   printf("connection made\n");
g_object_get(entry1,"text",&p,NULL);      g_object_get(combo,"text",&q);
   printf("%s \n",q);
   char *sql = g_strdup_printf ("INSERT INTO                                    sample(no,name)VALUES('%s','%s')", p,q);
   doSQL (conn,sql);
   g_free (sql);
  }
}

int main (int argc, char *argv[])
{
  const gchar *value;
  gtk_init (&argc, &argv);
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  box1 = gtk_hbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), box1);
  gtk_widget_show (box1);
  button = gtk_button_new_with_label(" Insert ");
  gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroyapp), NULL);
  gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(a), NULL);
  gtk_box_pack_start (GTK_BOX (box1), button, TRUE, TRUE, 0);
  entry1 = gtk_entry_new_with_max_length (50);
  gtk_box_pack_start (GTK_BOX (box1), entry1, TRUE, TRUE, 0);
  gtk_widget_show (entry1);
  items = g_list_append (items, "Banana");
  items = g_list_append (items, "Orange");
  items = g_list_append (items, "Peach");
  items = g_list_append (items, "Strawberry");
    combo = gtk_combo_new();
    gtk_combo_set_popdown_strings (GTK_COMBO (combo), items);
    gtk_box_pack_start (GTK_BOX (box1), combo, TRUE, TRUE, 0);
    gtk_widget_show (combo);
    gtk_container_border_width (GTK_CONTAINER_Window), 15);
    gtk_widget_show(button);
    gtk_widget_show(window);
    gtk_main();
    return 0;
}

The Error I am getting is

connection made

(button1:6266): GLib-GObject-WARNING **: gobject.c:946: object class `GtkCombo' has no property named `text'
(null)
INSERT INTO sample(no,name) VALUES('32432','(null)')
result:

In the place of that combo box null value is being inserted.
 
 
regards
sameer.
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux