Link to home
Start Free TrialLog in
Avatar of caoidx1
caoidx1

asked on

Ms Access

Could some one give an example App on how to connect to an Access database using DAO or OBDC?  I do not want to use the BDE.
Avatar of chrb
chrb

Have you checked DSP or Torry's Delphi page? I have found some examples there. If you want I can find them for you.

Chr
I used this once can't remember were I got it though

to create a link to the ODBC driver

1. First start the BDE Administrator from the Windows Start Menu
(it will be in the Delphi 3.0 folder.)

2. Now select Object|ODBC administrator from the main menu.
(this will bring up a list of currently installed drivers.)

3. Choose Add and then select the ODBC driver you would like to create
a data source for, then click on OK.

4. Next fill in the appropriate information for your driver.
(A minimal configuration will require the  Data Source Name field.
You will also need to fill in at least one other field that is a
location specifier for the data. This could be a path in the case of
Paradox or dBase tables or the Server field in the case of configuring
an Interbase ODBC driver.  Some non-exhaustive examples include; if

you are using Interbase you would select a path to a .GDB file, if
using Paradox or dBASE files you would specify the data directory
containing your tables or if you were using Oracle you would specify
the entry as it appears in your TNSNAMES.ORA file.  Once this is done
you have created a virtual driver and will be able to access your
database files through the datasource your created.)

Hope this helps if not just reject it

Later
BoRiS
Avatar of caoidx1

ASKER

What is the proposed answer?
I have a real answer for you. reject the current one.
Do you still want to know how to do this...I'll put up how to do it with native drivers now if you want to know how to use ODBC I'll answer that later

1) open a new application...File | New Application
2) click on the Data Access Tab in your component pallet
3) select the Database component and drop it on your form
4) double click the Database component to reveal a dialog box
5) under Name put MyTestDB
6) under Alias name leave it blank
7) under Driver name put MSACCESS
8) click on the button Defaults
you will see

DATABASE NAME=DRIVE:/PATH/DATABASE.MDB
USER NAME=
OPEN MODE=READ/WRITE
LANGDRIVER=
SYSTEM DATABASE=
PASSWORD=

in the box to the left

after DATABASE NAME= put in the drive and path and name of your Access database

9) click OK
10) in the object inspector (that thing that has the properties and events tabs) go to the Connected property and set it to true.  This should pop up a login box, leave the fields blank and hit OK.  If you don't get an error you did it right.
There are a couple reason that you have failed.  If you get an error like MSACCESS -102764 error Please look at this web page

http://support.microsoft.com/support/kb/articles/Q141/2/94.asp

it will tell you how to reregister the dll...this happens after installing 97 on a system that had 95 on it before.  Hop this helps ODBC it about the same in dificulty but you don't have as many "wacko" thinks that can happen...NOTE:these "things" only pertain to the initial set up Native drivers are about 20 times better than the ODBC. (this is my opinion...I only use Access for design and depoly using MSSQL)


ASKER CERTIFIED SOLUTION
Avatar of ssite
ssite

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