Reading MS Access mdb files in Delphi (for free)?

Marek Jedliński picture Marek Jedliński · Apr 10, 2009 · Viewed 11.3k times · Source

I'm looking for a Delphi component / library to open and read from an mdb (MS Access) database. I will not be writing to the db or displaying the data; just need to read the db using whatever sql Access supports.

This is for a personal side-project (programming is not my paying job), so I need a free or a very inexpensive solution that works with any of Delphi 6, Delphi 2007 or Delphi 2009 (Professional editions all). Performance doesn't matter, simplicity does :)

Answer

avar picture avar · Apr 10, 2009

http://www.teachitza.com/delphi/databasehowto.htm it is realy simple and easy task with 5-10 line of code. that was very usefull for me when i needed to just read some data from ms access files.

for starting u can use simple connection string like this

    DataSource := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + Filename +
    ';Persist Security Info=False';

  ADOConnection1.ConnectionString := DataSource;
  ADOConnection1.LoginPrompt := False;
  ADOConnection1.Connected := true;

  // ADOConnection1.GetTableNames(listbox1.items);

  AdoTable1.Connection := ADOConnection1;
  AdoTable1.ReadOnly := false; //if u want to make changes
  ADOTable1.active := false;
  ADOTable1.TableName := 'B2777'; //table name
  ADOTable1.active := true;

filnename is ur mdb file path+name. that is what i use for very simple tasks.