Author: Massimo Brini
Most programmers use the SQL Explorer which is installed by default with Delphi.
With the announced extinction of the BDE, an alternative is needed for everyday’s
common tasks. This is my solution.
How do I query an Access MDB File with ADO (no BDE installed)?
The SQL Explorer has been for years one of the most important tools I used.
Now that I decided to shift from BDE solutions to ADO, I needed an alternative for
the SQL Explorer which could gave me at least the same functionalities, so I
created this little Delphi project (which I called ADO Explorer) which gaves me the
main features a real programmer needs. In the next weeks I will prepare a second
article in which I will explain how to customize and empower this program, makin it
even a better solution that the Old, original, beloved SQL Explorer.
1. Open your Delphi 5 and create a new blank project.
2. On the form, drop these components:
A Memo component
An Edit component
An OpenDialog and SaveDialog component
3. Connect together the DB components (ADOConnection->ADOQuery->DataSource->DBGrid)
4. Insert in the first button’s OnClick Event handler this code:
1 procedure TForm1.Button1Click(Sender: TObject);
2 begin3 if ADOQuery1.Active then4 ADOQuery1.Close;
5 if ADOConnection1.Connected then6 ADOConnection1.Connected := False;
7 ADOConnection1.ConnectionString := Edit1.Text;
8 ADOQuery1.SQL := Memo1.Lines;
9 if UpperCase(Copy(Memo1.Lines, 1, 6)) = 'SELECT' then10 begin11 ADOQuery1.Open; // Result Set attended fro mthe operation12 end13 else14 begin15 ADOQuery1.ExecSQL; // No result set -> different method to open16 end;
5. Insert in the second button’s OnClick Event handler this code:
if OpenDialog1.Execute then
6. Insert in the third button’s OnClick Event handler this code:
if SaveDialog1.Execute then
7. Build & compile the project: the new ADO SQL Explorer is done!
The program can archive the most important queries used; it recognizes on its own
the correct method to use with the given query and can be used against virtually
every kind of OleDB or ODBC supported database.
The Sources of the program will be made available for download soon on my website (http://www.dreamscape.it) or can be asked directly by email to email@example.com.