Using Api.RetrieveColumns to get multi-valued count

Feb 27, 2014 at 6:38 AM
Is it possible to use Api.RetrieveColumns to get the number of values in a multi-valued column?
Or does that only work with Api.JetRetrieveColumns?
Developer
Mar 3, 2014 at 10:50 PM
I just checked, and no. I modified HowDoI.cs from the test suite to also try RetrieveColumns, and it doesn't work.
I've posted a fix below (passes the unit test, but I haven't thoroughly tested it). I'll incorporate this in to the next release, but I'm going on vacation tomorrow, so I'm not sure when it will be uploaded. ;)
            // Retrieve the number of column instances. This can be done with JetRetrieveColumns by setting
            // itagSequence to 0.
            JET_RETRIEVECOLUMN retrievecolumn = new JET_RETRIEVECOLUMN();
            retrievecolumn.columnid = tagColumn;
            retrievecolumn.itagSequence = 0;
            Api.JetRetrieveColumns(sesid, tableid, new[] { retrievecolumn }, 1);
            EseInteropTestHelper.ConsoleWriteLine("Api.JetRetrieveColumns retrieved {0} multi-values.", retrievecolumn.itagSequence);
            Assert.AreEqual(3, retrievecolumn.itagSequence);

            // Retrieve the number of column instances. This can be done with JetRetrieveColumns by setting
            // itagSequence to 0.
            StringColumnValue retrieveStringColumnValue = new StringColumnValue();
            retrieveStringColumnValue.Columnid = tagColumn;
            retrieveStringColumnValue.ItagSequence = 0;
            Api.RetrieveColumns(sesid, tableid, retrieveStringColumnValue);
            EseInteropTestHelper.ConsoleWriteLine("Api.RetrieveColumns retrieved {0} multi-values.", retrieveStringColumnValue.ItagSequence);
            Assert.AreEqual(3, retrieveStringColumnValue.ItagSequence);
If you edit ColumnValue.cs and add the second statement you can get it to work.
                        // Propagate the warnings and output.
                        for (int i = 0; i < columnValues.Length; ++i)
                        {
                            columnValues[i].Error = (JET_wrn)nativeRetrievecolumns[i].err;
                            columnValues[i].ItagSequence = (int)nativeRetrievecolumns[i].itagSequence;
                        }
-martin