Trying to use gnome_db_combo_sync()




I tried using gnome_db_combo_sync in my sample application, but it only
works the first time I call it. I have two combos, each of which uses a
recordset with the contents of one of these tables:

  CREATE TABLE type_a (name CHAR(20), id   INT);
  INSERT INTO type_a VALUES('Red',   100);
  INSERT INTO type_a VALUES('Green', 110);
  INSERT INTO type_a VALUES('Blue',  120);

  CREATE TABLE type_b (name CHAR(20), id   INT);
  INSERT INTO type_b VALUES('Tall',    100);
  INSERT INTO type_b VALUES('Average', 110);
  INSERT INTO type_b VALUES('Medium',  120);

  1) First, I select "Green" and "Tall" from each combo box.
  2) Next, I click Execute Search, which calls get_selected_value for each
     of the two combos. The combo's recordsets give me 110 and 100.
  3) I click the Execute Search button again (without repositioning the
     combo boxes), and I get 100 and 100, which are the initial values
     of the combo, but the first combo still shows Green (110) as the
     selection.
  
Here is get_selected_value():

gchar* get_selected_value(GtkWidget* combo, gint column_index) {

  Gda_Recordset* grs; /* The underlying record set */
  Gda_Field* field;   /* The field whose value we need */
  gchar buffer[64];  /* A buffer to hold the return value */
  
  /* Reposition the record set on the selected row */
  grs = gnome_db_combo_get_recordset(GNOME_DB_COMBO(combo));
  gnome_db_combo_sync(GNOME_DB_COMBO(combo));

  /* retrieve the field we're interested in and return it */
  field = gda_recordset_field_idx(grs, column_index); 
  gda_stringify_value(buffer, sizeof(buffer), field);
  fprintf(stderr, "GOT STRING: %s\n", buffer);
  return g_strdup(buffer); 

}

Is there a particular set of flags I should use when I create my recordset
if I intend to use gnome_db_combo_sync? Here is how it is created:

  rc = gda_recordset_open_txt(GDA_RECORDSET(grs), 
                              sql_buffer, 
                              GDA_OPEN_STATIC, 
                              GDA_LOCK_READONLY, 
                              0);

The complete example source (with a Makefile) is at:

  http://www.as220.org/~bjepson/gnome-db/gdaexample-02112000.tar.gz

Just let me know if there's any more information I give you about this.

Thanks,

Brian Jepson * (bjepson@ids.net)  *  http://users.ids.net/~bjepson



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