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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,c189348d4cc27bd2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-07 06:32:12 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!isdnet!newsfeed.icl.net!dispose.news.demon.net!demon!newspeer.clara.net!news.clara.net!news5-gui.server.ntli.net!ntli.net!news2-win.server.ntlworld.com.POSTED!not-for-mail From: "rohit.sharma" Newsgroups: comp.lang.ada References: <2gqo6.8730$925.800172@news6-win.server.ntlworld.com> <982ogg$64t$1@tribune.oar.net> <1Bkp6.5$Sz3.1480@read2.inet.fi> Subject: Re: Microsoft Access database on GNAT 3.04 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-Mimeole: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: <9yrp6.1357$sV.184224@news2-win.server.ntlworld.com> Date: Wed, 7 Mar 2001 14:24:51 -0000 NNTP-Posting-Host: 62.255.112.49 X-Complaints-To: abuse@ntlworld.com X-Trace: news2-win.server.ntlworld.com 983975173 62.255.112.49 (Wed, 07 Mar 2001 14:26:13 GMT) NNTP-Posting-Date: Wed, 07 Mar 2001 14:26:13 GMT Organization: ntlworld News Service Xref: supernews.google.com comp.lang.ada:5500 Date: 2001-03-07T14:24:51+00:00 List-Id: All these examples work very well with GNAT3.13 and GNATCOM-1.3. But I am looking for something under GNAT 3.04. Rohit "Anders Wirzenius" wrote in message news:1Bkp6.5$Sz3.1480@read2.inet.fi... > > WJT wrote in message <982ogg$64t$1@tribune.oar.net>... > ... > >A small example of connecting to an Access database, and loading up a > >Dataset with a SQL select statement would get me going. > ... > > The following code is a result of modifying examples in the Samples > directories in GNATCOM-1.3p for WinNT. Remove the HTML tags where they > appear. The SQL is made using MS Access query builder, hence the unnecessary > complexity of the SQL-command. > > Makefile: > > gnatmake -IC:\gnatcom-1.3p\binding -IC:\gnatcom-1.3p\samples\bindings -IC:\g > natcom-1.3p\samples %1 -largs -lodbc32 > > Ada code: > > with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; > with GNAT.IO; use GNAT.IO; > > with GNATCOM.Types; > with GNATCOM.BSTR; use GNATCOM.BSTR; > with GNATCOM.VARIANT; use GNATCOM.VARIANT; > with GNATCOM.Initialize; > > with ADO.uConnection_Interface; use ADO.uConnection_Interface; > with ADO.uCommand_Interface; use ADO.uCommand_Interface; > with ADO.uRecordset_Interface; use ADO.uRecordset_Interface; > with ADO.Fields_Interface; use ADO.Fields_Interface; > with ADO.Field_Interface; use ADO.Field_Interface; > > procedure Botnia is > use type GNATCOM.Types.VARIANT_BOOL; > > Connection : uConnection_Type; > Command : uCommand_Type; > Recordset : uRecordset_Type; > SQL : Constant > GNATCOM.Types.BSTR := To_BSTR ( > "SELECT Botniahalli.Botniahalli_Viite, > Botniahalli.P�iv�m��r�, " & > "Botniahalli.Alkaa, Botniahalli.Loppuu, > Joukkueet.Joukkuenumero, " & > "Botniahalli.Joukkue, Joukkueet.Joukkuenimi, " & > > "((Hour([Loppuu])-Hour([Alkaa]))*60+Minute([Loppuu])-Minute([Alkaa]))/30 " & > "AS Vuoroja, " & > > "Int(((Hour([Loppuu])-Hour([Alkaa]))*60+Minute([Loppuu])-Minute([Alkaa]))/30 > *[Hinta]+0.5) " & > "AS Vuokra, KenttaVuokrat.KenttaNimi, > Botniahalli.Botniahalli_Viite " & > "FROM (Botniahalli INNER JOIN Joukkueet ON " & > "Botniahalli.Joukkue = Joukkueet.Joukkuekoodi) " & > "INNER JOIN KenttaVuokrat ON " & > "Botniahalli.Kentt� = KenttaVuokrat.KenttaKoodi " & > "WHERE (((Botniahalli.Botniahalli_Viite) Is Not Null) > AND " & > "((Joukkueet.Joukkuenumero)=144 Or > (Joukkueet.Joukkuenumero)=152 Or " & > "(Joukkueet.Joukkuenumero)=172))"); > begin > GNATCOM.Initialize.Initialize_COM; > Put_Line ("Content-type: text/html" ); > New_Line; > Put_Line("Anders"); > Put_Line(""); > > Put_Line ("Create ADO Engine
"); > Create (Connection, ADO.CLSID_Connection); > > Put_Line ("ADO Version is : " & To_Ada (Get_Version (Connection))); > New_Line; > Put_Line ("Open Connection to Database
"); > > Put_ConnectionString > (Connection, > To_BSTR ("DSN=adademo") ); > > > Open (Connection, null, null, null, 0); > > Create (Command, ADO.CLSID_Command); > PutRef_ActiveConnection (Command, Pointer (Connection)); > > Put_CommandText (Command, SQL); > > Create (Recordset, ADO.CLSID_Recordset); > > Open (Recordset, > Source => To_VARIANT_From_Dispinterface (Command), > CursorType => ADO.AdOpenForwardOnly, > LockType => ADO.AdLockReadOnly, > Options => 0, > Free => False); > > MoveFirst (Recordset); > > while Get_EOF (Recordset) /= GNATCOM.Types.VARIANT_BOOL_TRUE loop > declare > Fields : Fields_Type; > begin > Attach (Fields, Get_Fields (Recordset)); > Put_Line ( "

" ); > for N in 0 .. Integer (Get_Count (Fields)) - 1 loop > declare > Field : Field_Type; > begin > Attach (Field, Get_Item (Fields, To_VARIANT (N))); > Put_Line (To_Ada (Get_Name (Field)) & " = " & > To_Ada (Get_Value (Field)) & "
"); > end; > end loop; > end; > MoveNext (Recordset); > New_Line; > end loop; > > Put_Line ("Close Connections"); > Put_Line(""); > Close (Recordset); > Close (Connection); > end Botnia; > > Another binding using ODBC you may find at Pascal Obry's home page > http://perso.wanadoo.fr/pascal.obry/adas.html > > Hope this helps. > Anders > >