Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: OLE Collection Collections ObjectCollectionOpen 1690
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
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.
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