Връзка с Access от Delphi

2 отговора 105 прегледа
#1

Връзка с Access от Delphi

С кой компонент и как мога да се свържа и тегля информация от
Access база данни?

Отговор
в отговор на chovek #2

Re: Връзка с Access от Delphi

Виж страницата ADO от палитрата с компоненти.

чети и дишай по-леко
Отговор
в отговор на chovek #3

решението

Два варианта успях като с BDE не се отваря Access2000 file
-----------------------------------------------------------------------------
ADO

If you have Delphi 5 Enterprise or Delphi 5 Professional with ADO Express, then you can use an ADOTable and in the ConnectionString property of the associated ADOConnection you can use the property editor to build the right connection string. For example:

Provider=Microsoft.Jet.OLEDB.4.0;
User ID=Admin;
Password=Password;
Data Source=D:\Path\dbname.mdb;
Mode=ReadWrite;
Extended Properties="";
Persist Security Info=False;
Jet OLEDB:System database="";
Jet OLEDB:Registry Path="";
Jet OLEDB:Database Password="";
Jet OLEDB:Engine Type=5;
Jet OLEDB:Database Locking Mode=1;
Jet OLEDB:Global Partial Bulk Ops=2;
Jet OLEDB:Global Bulk Transactions=1;
Jet OLEDB:New Database Password="";
Jet OLEDB:Create System Database=False;
Jet OLEDB:Encrypt Database=False;
Jet OLEDB:Don't Copy Locale on Compact=False;
Jet OLEDB:Compact Without Replica Repair=True;
Jet OLEDB:SFP=False
NOTE: It all goes in the same line.

This would open the database D:\Path\dbname.mdb using the ADO driver for Access databases (Microsoft.Jet.OLEDB.4.0). The username would be Admin without password (the default when you create an Access database). If you have set a password for the database, you should provide it in the Jet OLEDB:Database Password property. If you have set up security, then you should indicate your workgroups .MDW or .MDA file in the Jet OLEDB:System database property.


BDE

If like most of us you don't have ADO, you can use the BDE which provides a native driver (MSACCESS). In a Database component, set the following properties:

DatabaseName = any_name (or alias_name)
DriverName = MSACCESS
LoginPrompt = False
Params = PATH=d:\path
DATABASE NAME=d:\path\filename.mdb
TRACE MODE=0
LANGDRIVER=Access General
USER NAME=Admin
PASSWORD=your_password
OPEN/MODE=READ/WRITE
SQLPASSTHRU MODE=NOT SHARED
Value of the DatabaseName property of a Database object is the one you should use in the DatabaseName property of Table and Query components that represent tables and queries on this database (this is the way to "link" them to the Database object).

Отговор