Hello all,

I wrote this code

Excel.PivotTable pt = (Excel.PivotTable)wksheet.PivotTables(1);

try

{

pt.SourceData = new string[] { connection, query };

pt.RefreshTable();

}

catch

{

throw;

}

finally

{

System.Runtime.InteropServices.Marshal.ReleaseComObject(pt);

}

and it works, but there is one problem. If I open Profiler and debud code, I see that query is executed 4 times. 3 times in line "pt.SourceData = new string[] { connection, query };" and 1 times here "pt.RefreshTable();". It takes too long time. Where is the problem?