ODBCDatabase.DataSources

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

ODBCDatabase.DataSources() As RowSet

New in 2020r2

Supported for all project types and targets.

Returns a RowSet with a list of configured Data Source Names (DSN). Returns both User and System DSNs in a single RecordSet.

Notes

The instance of the ODBCDatabase does not have to be connected to a database in order to use this method.

The RowSet returned by DataSources has two columns. They are:

  • Name: The data source name
  • Description: The Name of the ODBC driver.

Microsoft provides additional information about the SQLDataSources ODBC function.

Example

This code gets all the ODBC data source names and adds them to a ListBox:

DataSourceList.DeleteAllRows

Var db As New ODBCDatabase

Var rs As RowSet
rs = db.DataSources

If rs <> Nil Then
While Not rs.AfterLastRow
DataSourceList.AddRow(rs.Column("Name").StringValue, rs.Column("Description").StringValue)
rs.MoveToNextRow
Wend
rs.Close
End If