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.



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.




The application object is no longer valid.


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


Import from database failed.


Invalid database specified.


Select statement is missing.


Transformation to XML failed.


Database import failed.




 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