> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, 8 December 1998 13:01
> To: Multiple recipients of list offtopic
> Subject: [DUG-OFFTOPIC]: Access Queries
>
>
> The "Select name from msysobjects where type = 5" works like a
> treat - from within Access -
> Thanks for that pointer folks.
> However Access seems reluctant to give up her secrets to the
> outside world.
You can use DAO to instruct the MS Jet Database Engine to execute whatever
you want.
Here is the code (Delphi 3) for a sample using DAO which runs a query to
produce the output from the SQL shown.
It uses OLE which is very slow. This can be sped up by using Com interfaces
or one of the third party products like ODA Programmed Access.
Note: DAO_TLB unit is an import of the DAO 3.5 Type Library
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DAO_TLB,
StdCtrls,OleAuto;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
AccessApp:OleVariant;
AccWorkspace:OleVariant;
AccDatabase:OleVariant;
AccRS:OleVariant;
SQLString:String;
Dummy:OleVariant;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
try
AccessApp:=CreateOLEObject('Access.Application')
except
ShowMessage('Can''t start Access');
end;
try
AccWorkspace:=AccessApp.DBEngine.CreateWorkspace('helplineUser','Admin',
'',dbUseJet);
except
ShowMessage('Can''t log on as user ');
end;
try
AccDatabase:=AccWorkspace.OpenDatabase('E:\Customers\CCCAD\Databases\Call
Registration Database - 97-2.mdb',False,False,'');
except
ShowMessage('Can''t open database file');
end;
SQLString:='SELECT Name AS QName FROM MSysObjects WHERE Type=5';
try
AccRS:=AccDatabase.OpenRecordSet(SqlString,dbOpenDynaSet);
except
ShowMessage('Can''t open Recordset with SQL');
end;
//AccRS.MoveLast; //only do this if
//AccRS.MoveFirst; // you need a record count
ListBox1.Items.Clear;
while not AccRS.EOF do
begin
ListBox1.Items.Add(String(AccRS.QName)); //Name property returns
the SQL statement
AccRS.MoveNext;
Application.ProcessMessages;
end;
end;
end.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Offtopic List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz