Azure SQL Connection from C#

Has anybody had any luck with connecting to a SQL database hosted by azure?

I’m assuming the connection fails due to some missing authentication, but can’t really debug what’s missing or why I’m unable to connect and post data. The code posted below works on my computer, but not on the iMX6. The code below works for local SQL databases just fine. Thanks, Matt

using System.Data.SQLClient;
			try
            {
                string connString = "Data Source=myDB.database.windows.net;Initial Catalog=databasename;User ID=******;Password=********";
                string cmdText = "insert into dbo.dBEvents(LocName, LocDesc) values ('x','y');";
                using (SqlConnection connection = new SqlConnection(connString))
                {
                    connection.Open();
                    int inserQueryCheck = 0;
                    using (SqlCommand command = new SqlCommand(cmdText, connection))
                    {
                        inserQueryCheck = command.ExecuteNonQuery();
                        if (inserQueryCheck > 0)
                        {
                            MessageBox.Show("INSERTED");
                        }
                    }
               }
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED");
            }

Dear @mdeiss

In our standard WinCe releases not all encryption types are included. In our article on VPN we list some of the missing features.

Have you seen our articles about Azure IoT? I must admit I don’t know how much this is related to an Azure SQL connection, but maybe you can find some information there which helps.

Regards, Andy

I think that in the article on Azure IoT, the section Azure IoT Suite is outdated.
As far as I know, Azure IoT Suite is now called Azure IoT solution accelerators.

Dear @vix
Thank you for pointing this out. We’re going to update the developer page article.
Regards, Andy