My C# code (which references Microsoft DAO 3.6 Object Library) contains objects called fromTable and toTable, both defined as DAO.TableDef objects.
I am trying to copy all the indexes of fromTable into toTable but when I try to compile the attached code snippet I get the following error message on the second foreach statement:
foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'
I also get the following error message that carries the same meaning on the next line:
'object' does not contain a definition for 'Append'
How can I copy a DAO.Index object if its Fields member is defined as a plain object?
foreach (DAO.Index fromIndex in fromTable.Indexes)
toIndex = toTable.CreateIndex(fromIndex.Name);
foreach (DAO.Field field in fromIndex.Fields)
toIndex.Fields.Append(toIndex.CreateField(field.Name, field.Type, field.Size));