I am using following code to run crystal report in activex control of crystal report in dynamics ax. every thing is working fine when In crystal report the value of "Use DSN Default Properties" is set to False. But I want to change its value from coding. I am stucked how can i change it from code. It is giving me error. on this line.
IConnectionProperty = INameValuePairs.add("Use DSN Default Properties",False);
Error:
Method 'add' in COM object of class 'INameValuePairs' returned error code 0x80070057 (E_INVALIDARG) which means: One or more arguments are invalid.
My code starts here;
public void run()
{
Com comapp;
Com reporting;
Com IDatabase;
Com IDatabaseTable;
Com IDatabaseSingleTable;
Com INameValuePairs;
Com INameValuePairs2;
Com INameValuePairs3;
COM tc;
COM IConnectionProperty2;
Com IConnectionProperty;
Com ds;
COM DLL_Name;
str paramwhole;
str paramfilename;
str paramCond;
str ViewYesNo;
int ret;
str selectionFormula;
COMVariant variant;
DialogButton diagBut;
str strMessage;
str strTitle;
;
super();
variant = new COMvariant(COMVariantInOut::OUT,COMVariantType::VT_BOOL) ;
//paramwhole = this.args().parm("'{Employee.empcode}'='11752'");
paramwhole = this.args().parm();
//paramwhole = this.args().parm("{Employee.empcode}='11752'");
//paramwhole = this.args().parm("{?DateFrom}='01/01/2021';{?DateTo}='03/03/2021';{Employee.empcode}='11752'");
comapp = new COM("CrystalRuntime.Application.11");
ret = strfind(paramwhole,"|",2,strlen(paramwhole));
//paramfilename = "e:\\rptTimeSheet.rpt"; //substr(paramwhole,2,ret-2) ;
paramfilename = "e:\\Report10.rpt"; //substr(paramwhole,2,ret-2) ;
ViewYesNo = substr(paramwhole,1,1);
reporting = comapp.openreport(paramfilename);
reporting.discardsaveddata();
comapp.LogonServer("crdb_odbc.dll","tms","tacs", "sa", "mypassword");
breakpoint;
IDatabase =reporting.Database();
IDatabaseTable = IDatabase.Tables();
IDatabaseSingleTable = IDatabaseTable.Item(1);
INameValuePairs = IDatabaseSingleTable.connectionproperties();
IConnectionProperty = INameValuePairs.add("Use DSN Default Properties",False);
paramcond = substr(paramwhole,ret+1,strlen(paramwhole));
reporting.RecordSelectionFormula(paramCond);
reporting.readrecords();
if(ViewYesNo == 'N')
{
variant.boolean(false);
reporting.PrintOut(variant);
}
else
{
ActiveX.ReportSource(reporting);
ActiveX.width(600);
ActiveX.height(350);
ActiveX.DisplayToolbar(true);
ActiveX.DisplayGroupTree(false);
ActiveX.ViewReport();
ActiveX.Refresh();
}
}