Creating and Maintaining Catalogs and Dictionaries with DTO : DtoDSNs Collection
 
DtoDSNs Collection
A collection of DtoDSN objects.
Properties
Count
Returns the number of members in a collection.
Item
Returns a specific member of a DtoDSNs collection.
Methods
Add method
Remove method
Remarks
Use the Count property to find the number of members in the collection.
Example
’ instantiate session object
Dim my_session as New DtoSession
Dim result as DtoResult
 
’ connect to a server
result = my_session.Connect("myserver", "username", "password")
 
’ now get DSNs collection
Dim my_dsns as DtoDSNs
Set my_dsns = my_session.DSNs
See Also
DtoDSN Object
DtoSession Object
Methods Detail
Add method
Add an item to a DtoDSNs collection and creates a DSN on the server.
Syntax
result = Collection.Add(Object)
Arguments
Collection
DtoDSNs collection to which to add object.
Object
A new DtoDSN object
Return Values
result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.
Remarks
This method takes a parameter of type object. Therefore, you are responsible for first instantiating the object and setting its properties before adding it to the collection.
Example
Dim result As dtoResult
Dim DSNs As DtoDSNs
Dim dsn As DtoDSN
 
Set dsn = New DtoDSN
 
' Set properties for new dsn
dsn.Name = "MyDemodata_DSN"
dsn.Description = "a sample DSN"
dsn.Dbname = "MyDemodata"
dsn.Openmode = dtoNormalDSNOpenMode
 
result = my_session.DSNs.Add(dsn)
If NOT result = Dto_Success Then
MsgBox "Error"+ my_session.Error(result)
End If
Remove method
Removes a DSN item from a DtoDSNs collection and deletes it from the server.
Syntax
result = Collection.Remove(dsn)
Arguments
Collection
Collection from which to remove object.
dsn
A variant containing either the index (starting with 1) or the name of the item you wish to remove from the collection
Return Values
result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.
Remarks
This method does not remove the associated database or database name.
Example
Dim result As dtoResult
Dim DSNs As DtoDSNs
result = my_session.DSNs.Remove("MYDSN")
If NOT result = Dto_Success Then
MsgBox "Error"+ my_session.Error(result)
End If