The following examples show how to use the Import object in Microsoft® Visual Basic®.
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
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