Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Oracle 10g connection

Posted on 2006-11-20
5
Medium Priority
?
363 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 26

Accepted Solution

by:
Tomas Helgi Johannsson earned 2000 total points
ID: 17986723
    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
ID: 17993670
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:Mohammed Nasman
ID: 17995012
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:Mohammed Nasman
ID: 17995023
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
ID: 18000365
thanks anyway

Dave
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

885 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