helpinghand
search
needassistance
 
How To
How to use the Mimer dbExpress Driver
Categories: Programming Examples, Tools and Interfaces
Introduction

This article describes how to create a small database application with Delphi 7 using the Mimer dbExpress Driver.

Description

The purpose of the application described herein is to provide an easy way to see and change the values in the CURRENCIES table of the Mimer SQL Example Environment database.

One task to deal with is that in the CURRENCIES table there are some missing EXCHANGE_RATE values that we want to fill in. For example, see the KWANZA currency. The application will aid for an easy update of the table.
Environment

The tools used to create this application are:

  • Delphi 7 as the client application development tool

  • Mimer dbExpress driver

  • Mimer SQL database server


You must have Borland Delphi 7 installed to create this example application. If you don't have Delphi 7, there is a trial version available for download from Borland at http://www.borland.com/products/downloads/download_delphi.html. If you don't have the Mimer SQL dbExpress driver or Mimer SQL Engine 9.2 or later installed, download them from http://developer.mimer.com/downloads.
Example

To get the database for the example, use the Mimer Administrator to create a new database called example_db. Tell the database installation wizard to create the Mimer SQL Example environment.

We are now ready to create the database application!

Start Delphi 7.

Click the dbExpress component tab:



Click the SQLConnection component button

Click somewhere on the form to place the SQLConnection component.



Double-click on the SQLConnection component that you placed on the form.

Click the Add Connection button



Select MIMER in the Driver Name field and write a Connection Name, in this case example1. Click OK.



Click on the example1 Connection name. Now, look at the Connection Settings table. Change the Database key value to example_db, set the User_Name key value to mimer_store and set the Password key value to GoodiesRUs.



Click the Test Connection button to verify the Connection. In the Database Login dialog box, write the password GoodiesRUs and click OK.



A dialog box saying Successfully Connected should be visible now. Click OK to close the Successfully Connected dialog box.

Click OK in the dbExpress Connections dialog to apply the changes made to the SQLConnection component and to close the dialog box.

Click the SQLTable component button in the dbExpress component palette.

Click somewhere on the form to place the SQLTable component. In the Object Inspector, set the SQLConnection property to SQLConnection1 and set the TableName property to CURRENCIES.



Click the Data Access component tab:



Click the DataSetProvider component button

Place the DataSetProvider component on the form by clicking somewhere on the form. In the Object Inspector, set the DataSet property to SQLTable1.



Click the ClientDataSet component button

Place the ClientDataSet component on the form by clicking somewhere on the form. In the Object Inspector, set the Active property to True and set the ProviderName property to DataSetProvider1.



Click the DataSource1 component button

Place the DataSource1 component on the form by clicking somewhere on the form. In the Object Inspector, set the DataSet property to ClientDataSet1.



Click the Data Controls component tab:



Click the DBGrid component button

Place the DBGrid component on the form by clicking somewhere on the form. In the Object Inspector, set the DataSource property to DataSource1.



Click the Standard component tab:



Click the Button component button

Place the Button component on the form by clicking somewhere on the form. In the Object Inspector, set the Caption property to &Update. Double-click on the Update button on the form to create code for the OnClick event. Add the following code to the Button1Click procedure:

ClientDataSet1.ApplyUpdates(-1);


The Button1Click procedure should look like this:

procedure TForm1.Button1Click(Sender: TObject);
begin
ClientDataSet1.ApplyUpdates(-1);
end;


You can now arrange the components to give the application a look that suits you. Here is a picture on how the supplied example project is arranged:



You are now ready to run the application. Click the Run button in the Run toolbar. (As an alternative you can choose the Run option in the Run menu or press F9 to run the application). You should now see a Database Login dialog box. This dialog box will connect to the example1 database that we defined in the SQLConnection component. The User Name field displays mimer_store, but the password field is empty. Write GoodiesRUs in the password field and click OK.

The application should now display a grid covering the CURRENCIES table with the three columns CODE, CURRENCY and EXCHANGE_RATE. There is also an Update button which is used to commit grid changes to the database.

Here is a picture of the application running:





Notes

This article can also be used if you are developing in Borland C++ Builder. Actually, this example procedure would look exactly the same!

The Mimer dbExpress Driver is distributed for free under the terms of the GNU Lesser General Public License.
Links

The complete sample application and the source code (right-click and 'Save Link Target As...').

The Mimer SQL download page.

The Borland Delphi home page.

The Mimer dbExpress Driver is based upon the open source project Open-dbExpress (dbxoodbc) which is available at http://sourceforge.net/projects/open-dbexpress.
Last updated: 2004-09-29

 

Powered by Mimer SQL

Powered by Mimer SQL