2

I developing mono project C# console application, I need to connect Azure Sql database service. I make this code, This occurs Exception "NotImplement Exception". I try to find solution. but Yet it did not implement SSL Encryption. Did this fix the problem now?

using System;
using System.Data;
using System.Data.SqlClient;
using Mono.Security;
namespace AzureConsoleApplication
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Console.WriteLine ("Hello World!");

            string connectionString = "Server=tcp:Server.database.windows.net,1433;Database=TestDatabase;" +
            "User ID=ID@Servername;Password=password;" +
            "Trusted_Connection=False;Encrypt=true;Connection Timeout=30;";
            IDbConnection dbcon;
            using (dbcon = new SqlConnection(connectionString))
            {
                dbcon.Open ();
                using (IDbCommand dbcmd = dbcon.CreateCommand())
                {
                    string sql = "SELECT * FROM MyTable1;";
                    dbcmd.CommandText = sql;
                    using (IDataReader reader = dbcmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            string first = (string)reader ["ID"];
                            string twice = (string)reader ["Col1"];
                            Console.WriteLine ("ID : " + first + "Col1 : " + twice);
                        }
                    }
                }
            }
        }
    }
}

1 Answer 1

1

Last I checked Mono does not support SSL for connecting to a SQL database.

https://github.com/mono/mono/blob/master/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs#L765

It's a gross hack, but at my current company we created a linked server on a local SQL server and then made our database calls route through that.

What's funny is that the SQL client for node.js does support SSL. =)

1
  • I'd run whole stuff in a docker container bridging TLS with stunnel.
    – Igor Gatis
    Jan 15, 2018 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.