Question

Biju Nambiar on Fri, 02 Dec 2016 06:41:40


Hi ,

I'm new to VSTO programming,I have a pivot table which is taking data from SQL Server.I just want to change the data source of this pivot table programatically.

string con = @"OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=PivoteNew;Data Source=BIJUC\SQL2012DEV";

           

wrkcon = newWorkbook.Connections.Add2("PivoteNew", " ", con, "Student");

pvttable = Globals.ThisAddIn.Application.ActiveSheet.PivotTables("PivotTable2");

          

 pvttable.ChangeConnection(wrkcon);

pvttable.RefreshTable();

This is my code,but throwing an error.

Appreciated your valuable comments.


Sponsored