Solved

Oracle 10g connection

Posted on 2006-11-20
5
348 Views
Last Modified: 2011-04-14
hi All,
I noticed there is quite a lot of discussion but couldnt find exactly what I was after.
I am wanting to connect to an Oracle database, I have the client installed which is Oracle (oraclient10g_home), I also have a view setup and an ODBC connection to that view. I am using Delphi 7 Enterprise and have the DOA40D7 component installed.
I want to query someinformation outof the database. I do not need to write anything back to the database - read only.
What would be the fastest and best way to perform this query?
I was planning to use the DOA components but cant seem to figure them out? although there may be a better way, I am open to suggestions.
Could someone also provide me with some simple code to show how it would work e.g a simple tool to alow me to enter the service name, user and password - this would return a list of tables/views, and also allow me to select one of these and run a select * (or even select count(*)  or similar.

thanks for your help

regards

Dave
0
Comment
Question by:monitorwa
  • 2
  • 2
5 Comments
 
LVL 24

Accepted Solution

by:
Tomas Helgi Johannsson earned 500 total points
Comment Utility
    Hi!

There is always ADO which is easy to use and manage.
Another set of components (freeware) is AnyDAC http://www.torry.net/quicksearchd.php?String=AnyDAC&Title=Yes
which is very powerfull and not so confuseing.

Regards,
  Tomas Helgi
0
 

Author Comment

by:monitorwa
Comment Utility
Hi Tomas - figured it out anyway but since you are th eonly one who answered will gladly give you th epoints

thanks

Dave
0
 
LVL 22

Expert Comment

by:mnasman
Comment Utility
Hi Dave,


  I have made very small sample that will connect to oracle, reterive all the tables and show them in listbox, double click on listbox will show you the table records inside datagrid, i used ADo components, but the idea should work for all types of database component(I don't have DOA, but I use ODAC)

//========== unit info
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, StdCtrls, DB, ADODB, DBCtrls;

type
  TForm1 = class(TForm)
    qry1: TADOQuery;
    ds1: TDataSource;
    dbgrdData: TDBGrid;
    lbl1: TLabel;
    lstTables: TListBox;
    con1: TADOConnection;
    procedure FormCreate(Sender: TObject);
    procedure lstTablesDblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  con1.ConnectionString := 'Provider=MSDAORA.1;Password=tiger;User ID=scott;Data Source=pro8500';
  con1.Open();
  qry1.SQL.Text := 'select * from tab';
  qry1.Open;
  while not qry1.Eof do
  begin
    lstTables.Items.Add(qry1.fieldByname('TName').AsString);
    qry1.Next;
  end;
end;

procedure TForm1.lstTablesDblClick(Sender: TObject);
begin
  if lstTables.ItemIndex >= 0 then
  begin
    qry1.Close;
    qry1.SQL.Text := 'select * from ' + lstTables.Items[lstTables.itemIndex];
    qry1.Open;
  end;
end;

end.

//======== form info

object Form1: TForm1
  Left = 244
  Top = 247
  Width = 587
  Height = 441
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object lbl1: TLabel
    Left = 16
    Top = 8
    Width = 32
    Height = 13
    Caption = 'Tables'
  end
  object dbgrdData: TDBGrid
    Left = 16
    Top = 208
    Width = 553
    Height = 193
    DataSource = ds1
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object lstTables: TListBox
    Left = 16
    Top = 32
    Width = 193
    Height = 169
    ItemHeight = 13
    TabOrder = 0
    OnDblClick = lstTablesDblClick
  end
  object qry1: TADOQuery
    Connection = con1
    Parameters = <>
    Left = 248
    Top = 120
  end
  object ds1: TDataSource
    DataSet = qry1
    Left = 264
    Top = 80
  end
  object con1: TADOConnection
    LoginPrompt = False
    Left = 232
    Top = 80
  end
end

============

HTH

Regards
Mohammed Nasman
0
 
LVL 22

Expert Comment

by:mnasman
Comment Utility
ohh too late, I open the page at morning, but i just post now, and didn't know it was answered :-)
0
 

Author Comment

by:monitorwa
Comment Utility
thanks anyway

Dave
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now