Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

Oracle 10g connection

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
monitorwa
Asked:
monitorwa
  • 2
  • 2
1 Solution
 
Tomas Helgi JohannssonCommented:
    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
 
monitorwaAuthor Commented:
Hi Tomas - figured it out anyway but since you are th eonly one who answered will gladly give you th epoints

thanks

Dave
0
 
Mohammed NasmanSoftware DeveloperCommented:
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
 
Mohammed NasmanSoftware DeveloperCommented:
ohh too late, I open the page at morning, but i just post now, and didn't know it was answered :-)
0
 
monitorwaAuthor Commented:
thanks anyway

Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now