Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

getdatasources

Return names of ODBC and JDBC data sources

Syntax

d = getdatasources

Description

example

d = getdatasources returns the names of valid ODBC and JDBC data sources on the system.

Examples

collapse all

Connect to a database using its data source name.

Retrieve all ODBC and JDBC data source names on the system.

d = getdatasources
d =

  1×11 cell array

  Columns 1 through 3

    'Excel Files'    'MS Access Database'    'MS SQL Server'

...

d is a cell array of character vectors. Each character vector is a data source name that is defined on the system.

Use the data source name in the database function to connect to a database at the command line. Or, in the Database Explorer app, click New Query and then select the data source name from the Data Source list.

Output Arguments

collapse all

Data sources, returned as a cell array of character vectors.

d is empty when the ODBC.INI file is valid, but no defined data sources exist.

For ODBC data sources, the getdatasources function retrieves data source names from the ODBC.INI file located in the folder returned by running:

myODBCdir = getenv('WINDIR')

The function also retrieves the names of data sources that are in the system registry but not in the ODBC.INI file.

For JDBC data sources, the getdatasources function retrieves data source names that you define using the JDBC Data Source Configuration dialog box in the Database Explorer app.

Note

If you define a JDBC data source with the same name as an existing ODBC data source, the Database Explorer app appends _JDBC to the data source name.

Introduced before R2006a

Was this topic helpful?