Hi guys,
Here is my issue experienced in NAV 2013 R2:
- There is a report that is using ADO automation and its components to export data from NAV into external SQL database.
- Running this report using NAS generates the following error message:
“Microsoft Dynamics NAV Server tried to send a callback to the client to create an automation object…Callback functions are not allowed…”.
Apparently, the issue is that NAS in NAV 2013 no longer supports creation of automation objects on the server, as already described
in this post.
With this, I was thinking about redisigning the code to use ADO.NET through .NET Interop instead of ADO. (Also, there was an idea to do the same via web-services, so that instead of NAV exporting data, external application would connect to the web-service and do the 'export' into SQL database). I still wonder which approach is the best in this scenario, but the following questions are related to ADO.NET.
So, previously when using ADO automation, the code for exporting data was built as follows:
- Create connection to the external SQL database
- Create and open a recordSet linked to a specifiic table of the external SQL database
- In a loop and using recordSet's cursor, populate recordSet with values from NAV database
- Insert values from the recordSet into a linked table of the external SQL database by running 'recordSet.UpdateBatch' method.
Now, when using ADO.NET the whole idea is changed a little and instead of using recordSets, ADO.NET operates with DataSets/DataTables and DataAdapters, where DataAdapter is acting like a bridge between a DataSet and a data source, in my case external SQL database.
Can someone please explain the logic or provide an example of how can I populate a very simple table in the external database (e.g. vendors) by using DataAdapter and DataSet/DataTable classes.
Thanks in advance.
Answers
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com
Here is a working example for exporting vendors from NAV into a table in external database:
I hope this helps someone.
The export is made into intermediary tables first, which are always cleared before the export. Then, data from intermediary tables is transferred to live tables using stored procedure. This is just in case you are wondering why am I doing it this way
Useful links:
http://msdn.microsoft.com/en-us/library/ms973217.aspx
http://dynamicsuser.net/blogs/waldo/arc ... ple-1.aspx