Link to home
Start Free TrialLog in
Avatar of LeTay
LeTay

asked on

Need sample of code accessing Oracle database with either ADO or BDE components

I use ADO to access a MS/SQL database
I need now to acces an Oracle (9) database
A couple of connection samples and queries syntax with ADO will be what I am looking for
Also, what do I have to install on my PC (Oracle layer) ?
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

    Hi!

If you don't have Oracle installed on the same computer you are developing on
then
1 you should download and install the Oracle Client.
2 Setup an ODBC connection to the database
3 and connect to the database using TADOConnection with the ODBC name you choose.

Everything else should be the same (that's if you follow the ANSI92/99 SQL standard in
your queries.

Regards,
  Tomas Helgi
ASKER CERTIFIED SOLUTION
Avatar of bhavesh_joshi
bhavesh_joshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Balshe
Balshe

YOU CAN USE THIS CODE

PUT
DB, DBTables IN THE USES


USES
DB, DBTables;




var
  DBKEM:TDatabase;
  QRY:TQuery;
begin


   DBKEM:=TDatabase.Create(self);

   DBKEM.DatabaseName := 'DBKEM';
   DBKEM.DriverName := 'ORACLE';
   DBKEM.LoginPrompt := False;
   DBKEM.Params.Add('SERVER NAME=orasrv');
   DBKEM.Params.Add('USER NAME=useR1'      );
   DBKEM.Params.Add('NET PROTOCOL=TNS');
   DBKEM.Params.Add('OPEN MODE=READ/WRITE');
   DBKEM.Params.Add('SCHEMA CACHE SIZE=8');
   DBKEM.Params.Add('LANGDRIVER=');
   DBKEM.Params.Add('SQLQRYMODE=');
   DBKEM.Params.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT');
   DBKEM.Params.Add('SCHEMA CACHE TIME=-1');
   DBKEM.Params.Add('MAX ROWS=-1');
   DBKEM.Params.Add('BATCH COUNT=200');
   DBKEM.Params.Add('ENABLE SCHEMA CACHE=FALSE');
   DBKEM.Params.Add('SCHEMA CACHE DIR=');
   DBKEM.Params.Add('ENABLE BCD=FALSE');
   DBKEM.Params.Add('ENABLE INTEGERS=FALSE');
   DBKEM.Params.Add('LIST SYNONYMS=NONE');
   DBKEM.Params.Add('ROWSET SIZE=20');
   DBKEM.Params.Add('BLOBS TO CACHE=64');
   DBKEM.Params.Add( 'BLOB SIZE=32');
   DBKEM.Params.Add('OBJECT MODE=TRUE');
   DBKEM.Params.Add('PASSWORD=userpass');
//   DBKEM.Session.AutoSessionName:=true;
   DBKEM.Connected:=true;



 QRY:=TQuery.Create(self);
   QRY.DatabaseName :='DBKEM';
   qry.SQL.Add('select * from table');
   qry.Open;
    // do what you want
   qry.Close;