Link to home
Start Free TrialLog in
Avatar of donly9
donly9

asked on

Delphi & Access

Need to connect a delphi application (delphi 6) to an access (2000 version) database.

What are the steps that I need to take or any clues please?

Thank you
Avatar of inthe
inthe

steps to connect to access via odbc:

Odbc:

1:   Open Control Panel, and then select ODBC DataSources (32bit) .
2:   When the Data Source Administrator appears, Click Add.
3:   find the one that says  Microsoft Access Driver (*.mdb)
     click it and click finish.
4:   A dialog will popup called ODBC Microsoft Access Setup
5:   in "data source name" edit box well call it "MyAccess"
6:   description well say is "tesing msaccess connection".
7:   click select and find your .mdb file click ok to select it.
8:   click "advanced" and make sure login name and password are blank.
9:   close advanced.
10:  close microsoft access setup dialog
11:  close the  Data Source Administrator.

delphi:

1:  start or restart delphi if its already running.
2:  start a new project
3:  drop a ttable,tdbgrid,tdatasource,tdatabase on form.

    in object inspector:

4:  datasource1 dataset : table1
5:  dbgrid datasource   : datasource1
6:  database1 aliasname : MyAccess  
7:  database1 databasename : MyAccessDB //type a name instead of selecting one
8:  database1 loginprompt : false
9:  table1 databasename : MyAccessDB  //the name you typed is now selectable
10: table1 tablename : select a table
11: database1 connected : true
12: table1 active : true

or connect via ADO (from another q):

- Drop ADOConnection from ADO page
- On ConnectionString property of the ADOConnection component, click (...) button and click Build.
- Select Microsoft Jet 4.0 OLE DB Provider
- Click on Connection tab and select your Access database file.
- Turn LoginPrompt to False if you write the login name and password in your connection
- Drop ADOTable or ADOQuery
- In ADOTable or ADOQuery Connection property select Connection1
- ADOTable and ADOQuery are datasets so that they can treated as any normal BDE TTable and TQuery. You
can drop a DataSource and any data controls to be linked with your Access table .
The simplest case example:

a) add adotable,datasource and dbgrid

b) build adotable connectionstring, for example
1)Microsoft Jet...
2)choose database (C:\Program Files\Borland Shared\Data\dbdemos.mdb)
and login if you need

c) choose adotable tablename (country)

d) datasource1.dataset - adotable1

e) dbgrid1.datasource -  datasource1

if you make adotable Active, data are visible in design-time

Of course, you may use other db-aware components and ado components as well.
This is just starting point

Avatar of donly9

ASKER

Thank you inthe
www.opus.ch is what I use with Delphi 5 and Access 97.  Very fast...and free.
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from inthe

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer