Hi...
Sorry, some how I am unable to post questions on my old post, so its a new thread I am opening for further communication.
I wrote all my T-SQL code inside a job to import data into 6 user tables in AX ERP. The job executes perfectly fine and imports the data correctly. But when I copy-paste the same code inside my custom class method and call it from my C# code using business connector I get the following error.
"{Microsoft.Dynamics.BusinessConnectorNet.XppException: Method 'execute' in COM object of class 'ADODB.Connection' returned error code 0x80040E31 (<unknown>) which means: Query timeout expired.
at Microsoft.Dynamics.BusinessConnectorNet.Axapta.CallStaticClassMethod(String className, String methodName, Object[] paramList)
at Microsoft.Dynamics.BusinessConnectorNet.Axapta.CallStaticClassMethod(String className, String methodName, Object param1, Object param2)"
The code I used to call my custom AX class/method inside c# code looks like this.
object retVal = axapta.CallStaticClassMethod("myInsertClass", "myInsertMethod", taxType, 2);
Please suggest.
Thanks,
Preeti
*This post is locked for comments
Hello Preeti,
I'm not sure if that what you are trying to do is a good idea (why not directly executing the queries in your application via ADO.Net, but if it is what you need to do, I would suggest:
- using ADO.Net in your X++ code: floditt.blogspot.com/.../using-adonet-with-x.html
- Increase the timeout of the SqlConnection and SqlCommand
- you might whant to increase the connection timeout in the Connection-String:
msdn.microsoft.com/.../system.data.sqlclient.sqlconnection.connectionstring.aspx
Hope this helps :-)
Kind regards,
Florian
Hi, the T-SQL code inside job works fine when run from inside AX. But when I call the job using my business connector like this: axapta.CallJob("Job7");
I get the following error: "The method has been called with an invalid number of parameters.(C)\Jobs\Job7".
If I do the following:
AxaptaObject Args = axapta.CreateAxaptaObject("myArgs");
axapta.CallJob("Job7", Args);
I still get the following error:
"System.ArgumentException: The supplied method arguments are not valid."
Please suggest. When I pass this AxaptaObject parameter, how the parameter is defined inside the job? Because it does not accept AxaptaRecord parameter?
Please help.
Thanks,
Preeti
I fail to see why you would want to use AX to run COM/NET code and then call this using the business connector from a C# (.Net) program...
Why do you not call the database insert from your C# code directly?
Hi,
I have 6 queries to retrieve data from 6 tables in intermediate database and then import them into 6 AX ERP tables. Total no. of records to be imported in 6 tables is around 1900000. When I run the job I get the following error:
Method 'execute' in COM object of class 'ADODB.Connection' returned error code 0x80040E31 (<unknown>) which means: Query timeout expired.
how do we increase connection timeout in AX class? The example code in the job is below for one of the tables (out of 6).
COM adoConn;
COM recordSet, recordSet1, recordSet2;
COM fields;
COM field;
COMVariant fieldValue;
;
adoConn = new COM("ADODB.Connection");
adoConn.open("Provider=SQLNCLI;Server=(local);Database=myDB;Trusted_Connection=yes;");
recordSet = adoConn.execute("CREATE TABLE #Temp(TaxGroupID VARCHAR(25), TaxRecID BIGINT IDENTITY(0,1) NOT NULL)");
recordSet1 = adoConn.execute("insert into #Temp(TaxGroupID) select top 10 taxgroupid from taxgroup");
recordSet2 = adoConn.execute("insert into DynamicsAX1..myUserTable(TaxGroupID,recversion, recid) select TaxGroupID, 1, TaxRecID from #Temp");
One of the tables has 1238767 records out of 1900000 and mostly I get the error for this. When I run the job by commeting this piece of code which imports 1238767 data, then job executes successfully. But when I include this table, I get timeout expired. Once I get this exception, then even if I comment this part of code again, it keeps on throwing the same exception and I have to restart Sql Server Services.
Please suggest.
as i can understand you can update some records in a job
, but when you transfer to in a method it fails..
are you sure that is your axapta class correctly initialize in c# ..
alternativetly you can call your job from c# either if it can helps you ..
ex:
axapta.callJob("JobName", args);
What happens when you call the job using the business connector?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156