Main Content

getdatasources

(To be removed) Return names of ODBC and JDBC data sources

The getdatasources function will be removed in a future release. Use the listDataSources function instead.

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.

Version History

Introduced before R2006a