WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Errors

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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)
exit

Answer:

There are two real ways to deal with collections of objects.

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
File Created: 2002:09:05:13:50:42
Last Updated: 2002:09:05:13:50:42