Import Automation Object Example

Meta Data Services Programming

Meta Data Services Programming

Import Automation Object Example

The following examples show how to use the Import object in Microsoft® Visual Basic®.

Importing from a File

The following example shows how to import object instance data from a file that contains exported data. The ImportXML method returns a collection. After you get the collection, you can enumerate the objects. To release the objects after the import concludes, set the objects to nothing.

dim oImp as new Import
dim oRep as new Repository
dim oRoot as RepositoryObject
dim ObjCol as TransientObjCol
set oRoot=oRep.Open "SERVER=MyServer;DATABASE=MyDB;UID=sa;PWD=MyPassword;"
set ObjCol = oImp.ImportXML(oRep, "c:\temp\myXmlFile.xml",NEWVERSION)
for each obj in ObjCol
. . .
next
Set oRoot=Nothing
Set oRep=Nothing
Set oImp=Nothing
Importing from a String

The following example shows how to import object instance data from a string stored in memory:

dim oImp as new Import
dim oRep as new Repository
dim oRoot as RepositoryObject

set oRoot=oRep.Open "SERVER=MyServer;DATABASE=MyDB;UID=sa;PWD=MyPassword;"
oImp.ImportXMLString oRep, sXMLStr, NEWVERSION
Set oRoot=Nothing
Set oRep=Nothing
Set oImp=Nothing

See Also

Export Automation Object Example

Importing XML

XML IImport Interface Overview