From: matthias-dated@mteege.de
Subject: passing hand arround a db connection
Date: 24 Aug 2004 09:32:00 GMT
Date: 2004-08-24T09:32:00+00:00 [thread overview]
Message-ID: <2p0g8gFfi977U1@uni-berlin.de> (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
next reply other threads:[~2004-08-24 9:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-24 9:32 matthias-dated [this message]
2004-08-24 12:51 ` passing hand arround a db connection 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox