The AddItem method adds a new DataSource object to the collection and returns a reference to the new object. You must specify the type of DataSource object to create, which must be one of:

Syntax

AddItem(Type as String, ItemName as String) as Object

Parameters
Type
The type of DataSource object to create (see the list of choices above).

ItemName
The name to assign to the new item.

Return Value
A reference to a newly created object.

Example
This example, which could be used as the code for the GetDataSources script for a Database object, adds three data sources to the collection, two ODBC and one SQLXML.

Visual FoxPro

lparameters toApplication as SQApplication, toDatabase as Database
local loODBCDataSource as ODBCDataSource, ;
  loXMLDataSource as SQLXMLDataSource
loODBCDataSource = toDatabase.DataSources.AddItem('ODBC', ;
  'SQL Server')
loODBCDataSource.Driver   = 'SQL Server'
loODBCDataSource.Database = 'Northwind'
loODBCDataSource.Server   = '(local)'
loODBCDataSource.UserName = 'sa'
loODBCDataSource.Password = 'somepassword'
loODBCDataSource = toDatabase.DataSources.AddItem('ODBC', ;
  'Access')
loODBCDataSource.Driver   = 'Microsoft Access Driver (*.mdb)'
loODBCDataSource.Database = 'C:\MyData\NWIND.MDB'
loXMLDataSource = toDatabase.DataSources.AddItem('SQLXML', ;
  'SQL Server over HTTP')
loXMLDataSource.BaseURL = 'http://localhost/northwind'

VBScript

function Main(Application, Database)
dim DataSource
set DataSource = Database.DataSources.AddItem("ODBC", _
  "SQL Server")
DataSource.Driver   = "SQL Server"
DataSource.Database = "Northwind"
DataSource.Server   = "(local)"
DataSource.UserName = "sa"
DataSource.Password = "somepassword"
set DataSource = Database.DataSources.AddItem("ODBC", _
  "Access")
DataSource.Driver   = "Microsoft Access Driver (*.mdb)"
DataSource.Database = "C:\MyData\NWIND.MDB"
set DataSource = Database.DataSources.AddItem("SQLXML", _
  "SQL Server over HTTP")
DataSource.BaseURL = "http://localhost/northwind"
end function

VBScript

function Main(Application, Database) {
var DataSource ;
DataSource = Database.DataSources.AddItem('ODBC', 
  'SQL Server') ;
DataSource.Driver   = 'SQL Server' ;
DataSource.Database = 'Northwind' ;
DataSource.Server   = '(local)' ;
DataSource.UserName = 'sa' ;
DataSource.Password = 'somepassword' ;
DataSource = Database.DataSources.AddItem('ODBC', 
  'Access') ;
DataSource.Driver   = 'Microsoft Access Driver (*.mdb)' ;
DataSource.Database = "C:\MyData\NWIND.MDB" ;
DataSource = toDatabase.DataSources.AddItem('SQLXML', 
  'SQL Server over HTTP') ;
DataSource.BaseURL = 'http://localhost/northwind' ;
}

See Also
AddItem | DataSources Collection