Altova XMLSpy 2024 Enterprise Edition

Method: ImportFromDatabase(pImportSettings as DatabaseConnection,pElementList as ElementList) as Document

 

Return Value

Creates a new document containing the data imported from the database.

 

Description

ImportFromDatabase imports data from a database as specified in pImportSettings and creates a new document containing the data imported from the database. Properties mandatory to be filled out are one of DatabaseConnection.File, DatabaseConnection.ADOConnection or DatabaseConnection.ODBCConnection and DatabaseConnection.SQLSelect. Additionally, you can use DatabaseConnection.AsAttributes, DatabaseConnection.ExcludeKeys, DatabaseConnection.IncludeEmptyElements and NumberDateTimeFormat to further parameterize import.

 

The parameter pElementList specifies which fields of the selected data gets written into the newly created document, and which are created as elements and which as attributes. This parameter can be NULL, specifying that all selected fields will be imported as XML elements.

 

See GetDatabaseSettings and GetDatabaseImportElementList for necessary steps preceding any import of data from a database.

 

Errors

1111

The application object is no longer valid.

1100

Invalid parameter or invalid address for the return parameter was specified.

1107

Import from database failed.

1112

Invalid database specified.

1114

Select statement is missing.

1117

Transformation to XML failed.

1120

Database import failed.

 

Example

 

 Dim objImpSettings As DatabaseConnection

 Set objImpSettings = objSpy.GetDatabaseSettings

       

 objImpSettings.ADOConnection = strADOConnection

 objImpSettings.SQLSelect = "SELECT * FROM MyTable"

       

 Dim objDoc As Document

 On Error Resume Next

 Set objDoc = objSpy.ImportFromDatabase(objImpSettings, objSpy.GetDatabaseImportElementList(objImpSettings))

 ' CheckForError here

© 2018-2024 Altova GmbH