From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f51c726168257d12,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: matthias-dated@mteege.de Newsgroups: comp.lang.ada Subject: passing hand arround a db connection Date: 24 Aug 2004 09:32:00 GMT Sender: Matthias Teege Message-ID: <2p0g8gFfi977U1@uni-berlin.de> X-Trace: news.uni-berlin.de sYEklNCu0lcT4X5qY4XkigUYoto4XfUX4jj+ggm0infsl4S2fp X-Orig-Path: not-for-mail User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.10-STABLE (i386)) Xref: g2news1.google.com comp.lang.ada:2955 Date: 2004-08-24T09:32:00+00:00 List-Id: 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