On the Connection to External Database tab you can define the object type to use a connection to an external database.
The "Connection to External Database" tab of the "New Object Type" dialog.
To import and edit objects in an external database, establish a connection to it. M-Files can be configured to connect to, for instance, the company customer database.
M-Files Server uses the connection definition to establish an OLE DB connection to an external database. The syntax of the connection definition depends on the OLE DB supplier used to establish the connection to the external database. If Open Database Connectivity (ODBC) is required to establish a connection, the data store has to be accessed over OLE DB and ODBC. The specific connection definition depends on the database.
Note that for technical reasons, M-Files Admin displays those OLE DB providers that are available on the computer running M-Files Admin. However, the M-Files server can reside on a different host. Ensure that the selected OLE DB connection definition works from the M-Files server.
Provider recommendations
Database | Provider |
---|---|
MS SQL Server | Microsoft OLE DB Provider for SQL Server. |
Access | Microsoft JET OLE DB Provider. |
Excel | Microsoft JET OLE DB Provider. Also, set Extended Properties to "Excel 8.0;". Use the Define name functionality to define the data area in Excel. This named Excel data area corresponds to a database table. The values in the first row of the data area become the column titles of a table. |
MySQL | Microsoft OLE DB Provider for ODBC Drivers (MySQL Connector/ODBC).
In connection settings, select Microsoft OLE DB Provider for ODBC Drivers as the provider and the system data source you defined as the data source. The default collection in the connection settings remains empty. Thus you only define the database in the driver settings. You can also use MySql.OLEDB Provider with MySQL. |
M-Files Server uses the SELECT statement to retrieve records from an external database.
Examples of SELECT statements:
SELECT CustomerNumber, CustomerName FROM Customer
SELECT ID, Name + ' ' + Department FROM Company
SELECT ID, Name, CustomerID FROM Contacts
SELECT * FROM Customer
Fetches the data defined in the SELECT statement into the Columns field.
The Columns field displays correspondences between columns fetched from an external database and document vault property definitions. You can edit the correspondences between source columns and target properties. Object types must always correspond to a unique ID and name. Subtypes must also correspond to the columns of the owner object. If the external database field can be updated using the UPDATE database statement, you can define the Update field accordingly. The Add field is used to specify the fields that can be added to the external database via the INSERT INTO statement.
When you edit an object in M-Files, M-Files Server edits the corresponding record in the external database using an UPDATE statement. Use a question mark (?) to signal columns to be updated.
Examples of UPDATE statements:
UPDATE Customers SET CustomerName = ? WHERE CustomerID = ?
UPDATE Contact SET Name = ?, CustomerID = ? WHERE ContactID = ?
When you create a new object in M-Files, M-Files Server adds a corresponding record in the external database using an INSERT INTO statement. Use a question mark (?) to indicate the value of each column.
Examples of INSERT INTO statements:
INSERT INTO Customers( CustomerName ) VALUES( ? )
INSERT INTO ContactPersons( Name, CustomerID ) VALUES( ?, ? )
When you delete an object from M-Files, M-Files Server deletes the corresponding record in the external database using a DELETE statement. Use a question mark (?) for the ID of the record to be deleted.
Examples of DELETE statements:
DELETE FROM Customers WHERE CustomerID = ?
DELETE FROM Contacts WHERE ContactID = ?
You can temporarily disable the external connection by selecting the Disabled checkbox.