FR/FAQ/Base/Se connecter à une base Microsoft Access

From Apache OpenOffice Wiki
< FR‎ | FAQ‎ | Base
Revision as of 19:01, 7 October 2007 by Jfnif (Talk | contribs)

Jump to: navigation, search

(traduction en cours)

Cet article décrit la manière de se connecter à un fichier de base de données Microsoft Access lorsque vous travaillez en environnement Microsoft Windows. Pour accéder à ce type de bases à partir d'autres systèmes, les articles ne sont pas encore terminés (ni traduits). Veuillez vous reporter à http://dba.openoffice.org/drivers/mdb/index.html.

Pré-requis sous Windows

La description qui est faite ici a été testée sous WinXP Familial. Il est possible que le fonctionnement sous d'autres versions soit légèrement différent.

Le type de fichier MDB est apparu avec MS Access 97 (MS Office 8) et a été utilisé jusqu'à la version MS Access 2003 (MS Office 11). Il peut être géré au moyen du moteur de bases de données "Jet 4.0". MS Access 2007 (MS Office 12) utilise le type de fichiers ACCDB, qui utilise un moteur de base de données Jet modifié, renommé en "Access Database Engine" (ACE).

Ces versions ne sont pas compatibles. D'une part ACCDB ne comporte pas de notions de sécurité basée sur l'utilisateur, d'autre part vous pouvez travailler avec des pièces jointes à l'intérieur du fichier de données par exemple.

Les deux verisons peuvent être accédées en utilisant un "driver ODBC" ou un "OLE DB provider". D'anciennes versions de Microsoft Windows (p.ex. Win98) peuvent ne pas comporter d'emblée le nécessaire pour gérer des fichiers MDB. Les fichiers manquants peuvent être téléchargés depuis http://msdn2.microsoft.com/en-us/data/aa937730.aspx. Vous aurez sans doute besoin du “Jet 4.0 Service Pack” et des “Microsoft Data Access Components (MDAC)”. WinXP inclut ces fichiers d'emblée. Pour accéder à des fichiers ACCDB, vous aurez sans doute besoin des composants “ 2007 Office System Driver: Data Connectivity Components”. La recherche du terme AccessDatabaseEngine (sans espaces) dans le centre de téléchargement de Microsoft vous mènera au lien de téléchargement. Même sous WinXP, ces fichiers ne sont pas fournis automatiquement.

Type de connexion (Étape 1 de l'Assistant)

Démarrez l'Assistant par Fichier > Nouveau > Base de données ou encore en appelant le menu Base de données dans le démarrage rapide d'OOo.

Dans la première étape, choisissez Se connecter à une base de données existante. Ouvrez la liste déroulante et choisissez Microsoft Access, ADO ou ODBC. Le contenu des étapes suivantes dépend du type de connexion choisi ici. Lorsque la connexion sera effective, elle sera mentionnée sur la gauche de la barre d'état.

Paramétrage de la connexion (Étape 2 de l'Assistant)

Microsoft Access

Fichiers de type MDB 
Choisissez MDB sur la deuxième page de l'Assistant. OOo utilise une connexion ADO dont tous les paramètres sont positionnés à leur valeur par défaut. Si votre base est protégée par mot de passe, vous ne pourrez donc pas employer cette méthode.
Fichiers de type ACCDB 
La gestion simplifiée de l'option Microsoft Access n'est pas encore disponible pour le format ACCDB.

ADO

Enter the Datasource URL on the second page of the wizard. That doesn't mean the path and filename of your database file, but it is the so called “connection string”.

Generating the Connection String

If you don't know the connection string, click on Browse. This opens the “ Universal Data Link (UDL) Wizard” of Windows. You see a dialog with the title Data Link Properties. The dialog pages Provider, Connections, Advanced, and All can be used in any order. When you close the dialog, the field Data source URL contains the constructed connection string.

Dialog Page Provider
File type MDB
Choose Microsoft Jet 4.0 OLE DB Driver
File type ACCDB
Choose Microsoft Office 12.0 Access Database Engine OLE DB Provider
Dialog Page Connections
File type MDB
Enter absolute path and file name of your MDB-file or click on the -button to use a file picker to choose your file.
If you have got a users administration for your database, enter the user name here, otherwise leave the default Admin unchanged. Let the option Blank Password unchanged too, password setting doesn't work here.
File type ACCDB
Enter absolute path and file name of your ACCDB-file here. A file picker is not available. The file type ACCDB doesn't know user administration, leave the default settings Admin and Blank Password unchanged.
Dialog Page Advanced

On the page Advanced you can constraint the access to the database. The default read/write is used without being checked.

Dialog Page All

Here you can set additional initializations for the OLE DB provider. Look at Microsoft site for further information.

Examples:

  • If your Access database file has got a password, you must enter it here. Choose the item Jet OLEDB Database Password and click on Edit Value. Enter the password there.
  • For a MDB-file the item JetOLEDB:System database contains path and name of the workgroup information file. Default in WinXP Home is c:\Windows\System32\system.mdw. You must enter it, if not “Admin” but another user is going to access the database.

At last go to the page Connections and test the connection. If you get an error message, you have to remove the error, otherwise no connection is possible. Finish the UDL-wizard with OK.

Now you are inside OOo again. Clicking on Next>> leads you to Setup User Authentication.

ODBC

On the second page of OOo database wizard enter the name of the ODBC data source. With Browse you get a list of all existing ODBC data sources.

Registering an ODBC Data Source

If you haven't register your Access database as ODBC data source in Windows, click on Browse and then on Organize… You come into the Microsoft dialog „ODBC Data Source Administrator“. On WinXP you can run the same dialog via Control Panel → Administrative Tools → Data Sources (ODBC) previously.

Choose one of the DSN-tabs and click on (German) Hinzufügen. Use Microsoft help to decide, which one is correct for you. If you will connect with a File DSN, you cannot use it directly, but you need an additional ADO connection string. The database tables will be readonly in this case.

File type MDB
Choose one of the Microsoft Access Driver and click on (German) Fertig stellen.
File type ACCDB
Choose Microsoft Access Driver (*.mdb *.accdb) and click on (German) Fertig stellen.

On the next window (German) ODBC-Setup für Microsoft Access specify the data source name. That identifier will be shown in the selection list later on.

Clicking on (German) Auswählen opens a file picker, where you can select your database file.

File type MDB
If you have got an user administration for your database, and not Admin but another user is going to access the database, check the option (German) Datenbank in the section (German) Systemdatenbank. The button (German) Systemdatenbank… opens a file picker. In WinXP Home the default file to choose is c:\Windows\System32\system.mdw.

If your Access database file is password protected, you can click on (German) Erweitert and enter the password there. But then the password is stored readable in the ODBC information in the registry, therefore it is no good idea. Leave the field (German) Benutzername empty.

You can find further settings in (German) Erweitert and (German) Optionen>>. For example you can check opening (German) exclusive there, however then you will be unable to hide tables in OOo.

Leave the dialogs with OK until you get the OOo dialog Data Source. The new data source should be included in the list. Choose it and click on OK. Next>>.

ODBC File DSN

Choose connection type ADO and click on Browse to generate the connection string.

Dialog page (German) Provider
Choose "Microsoft OLE DB Provider for ODBC Drivers".
Dialog page (German) Verbindung
Choose (German) Verbindungszeichenfolge verwenden. Click on (German) Erstellen, mark the File DSN in the provided list and click OK, OK.

If the Access database file needs a password, you must enter it then.

Test the connection, OK.

Follow the description for ODBC in Wizard Step 3.

Setup User Authentication (Wizard Step 3)

ADO

Leave the fields empty. Test the connection. Next>>

ODBC

If your database is password protected and you haven't enter the password in the ODBC informations, check Password required.

File type MDB
If not Admin but another user shall work with the database, enter the user name here, otherwise leave the field empty.
File type ACCDB
The file type doesn't know user management, leave the field User name empty.

Test the connection. If necessary enter the password now. Next>>

Save and Proceed (Wizard Step 4)

If you want to use the data source in other office modules, for example for mail merge, you must check the option Yes, register the database for me. After click on Finish you determine file name and folder to save for the Open Document Base file. Now you can work with the database.

Properties of the Connections

Access to the Tables

File type MDB
You can alter the content of the table, add and remove records.
File type ACCDB
In an ADO connection you can only read the tables but not write them. It is not sure whether this is fault of OOo. In an ODBC connection you have got read and write access to the tables.

You are able to define new tables. However in both connection types you cannot alter the structure of existing tables.

MS queries are handled as views in OOo and shown in the table container.

See also

MSDN Office Development http://msdn2.microsoft.com/en-us/library/ms400535.aspx


Autor: Regina Henschel 14 September 2007
Please do not change the logical content of this site without acknowledge of the author or the OOo QA Project Lead/Co-Leads.

Personal tools