Database Toolbox Previous page   Next Page

Setting Up a Data Source

Before you can connect from the Database Toolbox to a database, you need to set up a data source. A data source consists of data that you want the toolbox to access, and information about how to find the data, such as driver, directory, server, or network names. You assign a name to each data source.

  1. If you have Microsoft Access installed and want to use the examples in this documentation, first get the databases and prepare them:
    1. Get dbtoolboxdemo Database.
    2. Get SampleDB Database.
  2. Set up the data source--the instructions depend on your configuration:

Getting and Preparing Databases for Examples

If you want to use the examples in this documentation, get the databases and prepare them.

dbtoolboxdemo Database

The dbtoolboxdemo data source uses the tutorial database provided with the Database Toolbox, $matlabroot\toolbox\database\dbdemos\tutorial.mdb. Before you can set up this data source, you must perform the following actions:

  1. Using operating system features or the MATLAB copyfile function, copy tutorial.mdb to a different directory, one for which you have write access, and rename it to tutorial_copy.mdb.
  2. Using operating system features or the MATLAB fileattrib function, ensure you have write access to the tutorial_copy.mdb.
  3. Open tutorial_copy.mdb in Access. You might have to convert it to your version of Access. Save the converted version as tutorial.mdb.

SampleDB Database

The SampleDB data source uses the Microsoft Access sample database called Nwind.

  1. If you do not already have the sample database on your system, you can download it from the Microsoft Web site downloads page. The version referred to in this documentation is part of the Access 2000 downloads and is the Northwind Traders sample database, Nwind.exe. Run the file to create the Nwind.mdb database.
  2. Rename the file to Nwind_orig.mdb.
  3. Using operating system features or the MATLAB fileattrib function, ensure you have write access to Nwind_orig.mdb.
  4. Open Nwind_orig.mdb in Access. You might have to convert it to your version of Access. Save the converted version as Nwind.mdb.
  5. Using Access, create a table into which you will export MATLAB results:
    1. Open the Nwind database in Microsoft Access.
    2. Create a new table that has two columns, Calc_Date and Avg_Cost.
    3. For the Calc_Date field, use the default Data Type, which is Text, and for the Avg_Cost field, set the Data Type to Number.

    4. Save the table as Avg_Freight_Cost and close it. Access warns you that there is no primary key, but you do not need one. If you do designate a primary key, you can run the example as written only once because Access prevents you from inserting the same record twice.
  1. If you need more information about how to create a table in Access, see Microsoft Access help.


Previous page  Structured Query Language (SQL) Setting Up a Data Source for ODBC Drivers Next page

© 1994-2005 The MathWorks, Inc.