web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

D365FnO On-Pram integration with third party application (Inhouse solution) database.

(0) ShareShare
ReportReport
Posted on by 32

Hi experts

I am going to work on integration. I needs your guidance to start my integration development.

Requirement: Some master data want to share with third party app on the base of master data sales orders / purchase orders happens on third party application and third party application wants to pushed these orders details to D365FnO On-Pram version.

we needs to create sales-order/ purchase-orders in D365FnO On-Pram version.

Please some one guide which integration approch is best it will be helpfull if you share with me any example link.

Please advice.

I have the same question (0)
  • Suggested answer
    huijij Profile Picture
    19,811 on at

    Hi Abdul,

    Please refer to the discussion for the same topic:

    community.dynamics.com/.../d365fo-integration-with-on-premise-system-file-db

  • Shakoor Taj Profile Picture
    32 on at

    Hi Judy,

    Thank you for your response, let me check the link I will get back to you.

  • Shakoor Taj Profile Picture
    32 on at

    Hi experts,

    I am connecting the external Database in D365FO using SQLClient and Select Customers after selection I am updating the City of the Customers but my Update query is not working below is my Code:

    using System.Data.SqlClient;
    class RunnableClass2
    {
        public static void main(Args _args)
        {
            Counter     counter = 0;
    
            SqlConnection conn = new SqlConnection("Server=serverIp; Database=dataBaseName; User Id=UsrId; Password=pswd;");
            str sqlL = "SELECT TOP 10 * FROM Customers";
            SqlCommand command = new SqlCommand(sqlL, conn);
            System.Data.SqlClient.SqlDataReader reader;
            System.Data.SqlClient.SqlParameterCollection parameterCollection;
            new InteropPermission(InteropKind::ClrInterop).assert();
    
            try
            {
                conn.Open();
                try
                {
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        counter  ;
                        var custcode = reader.get_Item("custcode");
                        var custname = reader.get_Item("custname");
                        var shortname = reader.get_Item("shortname");
                        var custCity = reader.get_Item("city");
    
                        if(custcode == '000009')
                        {
                            str update="UPDATE Customers SET city = 'Lahore' WHERE custcode = '000009'";
                            SqlCommand updateCmd = new SqlCommand(update, conn);
                            updateCmd.ExecuteNonQueryAsync();
                        }
    
                        Info(strFmt("%1 - %2 - %3", prdcode,custname,shortname));
                    }
                    Info(strFmt("%1", counter));
                    reader.Dispose();
                }
                catch
                {
                    reader.Dispose();
                }
                catch(Exception::CLRError)
                {
                    reader.Dispose();
                }
                finally
                {
                    conn.Dispose();
                }
            }
            catch
            {
                conn.Dispose();
            }
            catch(Exception::CLRError)
            {
                conn.Dispose();
            }
            command.Dispose();
            CodeAccessPermission::revertAssert();
        }
    
    }

    I have debugged the issue, below is screenshot of debug windows.

    ErrorImage2.jpeg

    Someone help me in this error I am badly stuck at Updating record query.

  • Martin Dráb Profile Picture
    238,534 Most Valuable Professional on at

    Look at details of the exception. All I can say from your screenshot is that you have an invalid cast somewhere. For example, is CustCode a text field?

    You may prevent this kind of bugs by using a strongly-typed API instead of the old SqlCommand.

    It's strange if your code compiles at all, because ExecuteNonQueryAsync() requires a parameter and you didn't provide any. It's not a correct way of an asynchronous call anyway; rather use ExecuteNonQuery() instead.

    By the way, there is no point in calling Dispose() on success, on error and then in the 'finally' block, because the last one covers the other two. And you can simplify it with the 'using' statement.,

  • Shakoor Taj Profile Picture
    32 on at

    Thank you, Martin Drab, for your response.

    I have checked the details of the exception in the debug window and have not found any other errors apart from the one mentioned in the screenshot above. One thing to note is that the external database's customers table has varchar data types for fields such as custcode, custname, shortname, and city, but I am receiving values in a var type variable.

    Can you suggest if this could be an issue?

    Could you also share a link or example for a strongly-typed API.?

    My code compiles successfully with ExecuteNonQueryAsync() without any parameters. I have also tried using ExecuteNonQuery() with the same result.

    Any suggestion. 

  • Martin Dráb Profile Picture
    238,534 Most Valuable Professional on at

    'var' isn't a type. It's just a way of leaving the system to decide which type it is, based on what it on the right side. This may be the source of your problem; use a specific method for the given type, e.g. GetString().

    More robust frameworks can handle it for you. I've used Dapper, LINQ to SQL and Entity Framework, for instance, but there are surely many more.

  • Shakoor Taj Profile Picture
    32 on at

    Thank you, Let me check and get back to you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 605 Super User 2025 Season 2

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 437 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 348 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans