1690 ObjectCollectionOpen Error
Keywords: OLE Collection Collections ObjectCollectionOpen 1690
Question:
I am attempting to use the ObjectCollectionOpen on the 'Properties' collection in ADOX. However, I am receiving the error "1690: OLE unable to perform enumeration of the specified object", on the the line 'ObjectCollectionOpen..' Why am I getting this error?file = "C:\TEMP\NEW.MDB" ; change to suit your situation IF FileExist(file) == @TRUE FileDelete(file) Endif crstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%file%;Jet OLEDB:Engine Type=4" ;creates a new ACCESS Database, Type=4 is Office 97 Compatible oMDB = ObjectOpen("ADOX.Catalog") oMDB.Create(crstring) ;the following has the same effect as creating a Connection Object ;the issuing Open() oMDB.ActiveConnection = crstring message(crstring,"Database Created - %file%") tbl = oMDB.Tables(0) name = tbl.Name message("Table # %i%",name) props = tbl.Properties hEnum = ObjectCollectionOpen(props) x= 1 While 1 p = ObjectCollectionNext(hEnum) If p == 0 Then Break cName = p.Name cValu = p.Value message("Property %cName%",cValu) ObjectClose(p) EndWhile ObjectCollectionClose(hEnum) EndWhile ObjectClose(oMDB) exitAnswer:
There are two real ways to deal with collections of objects.
- If the object supports enumeration via the IEnumVARIANT Interface, then you can use the ObjectCollectionOpen, ObjectCollectionNext, and ObjectCollectionClose functions (See WIL help file for details).
Note: If you have a VB or WSH script you are attempting to translate into WinBatch, then you might see something like "FOR EACH" in the script. This is a good indicator that the object supports enumeration via the IEnumVARIANT Interface.
- If the object doesn't support enumeration via the IEnumVARIANT Interface, then it *must* have a way to reference the 'index' of the object in the collection. Maybe via Count and Item properties or by simply referencing the index number in parenthese.
Apparently the ADOX Properties object does not support enumeration via the IEnumVARIANT Interface. Therefore, in your case, you should be able to access the collection using the count and item properties...
file = "C:\TEMP\NEW.MDB" ; change to suit your situation IF FileExist(file) == @TRUE FileDelete(file) Endif crstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%file%;Jet OLEDB:Engine Type=4" ;creates a new ACCESS Database, Type=4 is Office 97 Compatible oMDB = ObjectOpen("ADOX.Catalog") oMDB.Create(crstring) ;the following has the same effect as creating a Connection Object ;the issuing Open() oMDB.ActiveConnection = crstring message(crstring,"Database Created - %file%") Objtbl = oMDB.Tables(1) name = Objtbl.Name message("Table",name) Objprops = Objtbl.Properties count = Objprops.Count For x = 0 to count-1 ObjpropsItem = Objprops.Item(x) cName = ObjpropsItem.Name cValu = ObjpropsItem.Value message("Property %cName%",cValu) Next ObjectClose(oMDB) exit
Article ID: W15221