I am having the following error;
Method 'add' in COM object of class 'INameValuePairs' returned error code 0x80070057 (E_INVALIDARG) which means: One or more arguments are invalid.
This error is being generated on the following line of code;
IConnectionProperty = INameValuePairs.add("Use DSN Default Properties",False);
I want to change the value of “Use DSN Default Properties” at runtime.
We have a TMS application, the reports of which we want to display in AX. These reports successfully run on TMS when “Use DSN Default Properties” is set to True. On setting it to False the reports do not work in TMS.

But with “Use DSN Default Properties=True” these reports are not working in AX. Following error is generated in AX.
Method 'readrecords' in COM object of class 'IReport' returned error code 0x80047E48 (<unknown>) which means: Logon failed.
Details: [Database Vendor Code: 18456 ].
This error is being generated on the following line of code;
reporting.readrecords();
When I change this value to False at report level, no error is then generated in AX at reporting.readrecords(); line. But again, they stopped working in TMS when its value is changed to False.
Hence, I want to change its value at runtime for running them in AX. How can I change the value of "Use DSN Default Properties" to False at runtime, any help will be appreciated.
Following is the complete code;
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:\\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", "Hubleather123");
// 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();
}
}