* passing hand arround a db connection
@ 2004-08-24 9:32 matthias-dated
2004-08-24 12:51 ` Stephen Leake
0 siblings, 1 reply; 6+ messages in thread
From: matthias-dated @ 2004-08-24 9:32 UTC (permalink / raw)
Moin,
I've playing with a small Ada application which uses GTK and APQ. I
build the GTK frontend with glade. Glade produced a file with the
callbacks for the frontend. Looks like that:
procedure On_Combo1_Realize
(Object : access Gtk_Combo_Record'Class)
is
Combo1_Items : String_List.Glist;
begin
String_List.Append (Combo1_Items, "One");
String_List.Append (Combo1_Items, "Two");
Combo.Set_Popdown_Strings (Window1.Combo1, Combo1_Items);
Free_String_List (Combo1_Items);
end On_Combo1_Realize;
Now I need the result of a database query. So I use:
procedure On_Combo1_Realize
(Object : access Gtk_Combo_Record'Class)
is
Combo1_Items : String_List.Glist;
C: Connection_Type;
Q : Root_Query_Type'Class := New_Query(C);
begin
Set_DB_Name(C,"db");
Set_Notify_Proc(C,Standard_Error_Notify);
Connect(C);
Prepare(Q, "SELECT foo ");
Append_Line(Q, " from bar group by foo");
Execute_Checked(Q,C);
loop
begin
Fetch(Q);
exception
when No_Tuple =>
exit;
end;
begin
Value(Q,1,R);
String_List.Append (Combo1_Items, R);
end;
end loop;
Combo.Set_Popdown_Strings (Window1.Combo1, Combo1_Items);
Free_String_List (Combo1_Items);
Disconnect(C);
end On_Combo1_Realize;
But I think it isnt a cool idea to use a new connection for each
query. What is the best way to use one connection for all querys?
Many thanks
Matthias
--
Matthias Teege -- http://www.mteege.de
make world not war
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: passing hand arround a db connection
2004-08-24 9:32 passing hand arround a db connection matthias-dated
@ 2004-08-24 12:51 ` Stephen Leake
2004-08-24 15:03 ` Matthias Teege
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Leake @ 2004-08-24 12:51 UTC (permalink / raw)
To: comp.lang.ada
matthias-dated@mteege.de writes:
> Moin,
>
> I've playing with a small Ada application which uses GTK and APQ. I
> build the GTK frontend with glade.
Ok. There is also the GtkAda mailing list (see
http://lists.act-europe.fr/mailman/listinfo/gtkada)
> <snip event handler stuff>
>
> But I think it isnt a cool idea to use a new connection for each
> query.
Right.
> What is the best way to use one connection for all querys?
Store the connection object in the top level window. In your event
handler, use Gtk.Widget.Get_Toplevel to get the top level window
object. For example (from one of my applications):
procedure On_Button_Add (Button : access Gtk.Button.Gtk_Button_Record'Class)
is
Table_View : constant Gtk_Table_View
:= Gtk_Table_View (Gtk.Button.Get_Toplevel (Button));
begin
To_Add (Table_View);
Default_Add (Table_View);
end On_Button_Add;
What database binding are you using? It doesn't look like GNADE.
--
-- Stephe
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-08-26 17:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-24 9:32 passing hand arround a db connection matthias-dated
2004-08-24 12:51 ` Stephen Leake
2004-08-24 15:03 ` Matthias Teege
2004-08-25 1:32 ` Stephen Leake
2004-08-25 5:28 ` Matthias Teege
2004-08-26 17:55 ` Warren W. Gay VE3WWG
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox