From 9b3e2dcd58c38a9f25dfd61ded11dfe876ebf01f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 19 Aug 2017 10:37:51 -0400 Subject: [PATCH] SqlConnectionStringBuilder to make connection string --- util/Setup/Helpers.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/util/Setup/Helpers.cs b/util/Setup/Helpers.cs index 211f4669b..be542ed10 100644 --- a/util/Setup/Helpers.cs +++ b/util/Setup/Helpers.cs @@ -1,4 +1,5 @@ using System; +using System.Data.SqlClient; using System.IO; using System.Security.Cryptography; using System.Text; @@ -92,9 +93,19 @@ namespace Setup public static string MakeSqlConnectionString(string server, string database, string username, string password) { - return $"Server=tcp:{server},1433;Initial Catalog={database};Persist Security Info=False;User ID={username};" + - $"Password={password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;" + - "Connection Timeout=30;"; + var builder = new SqlConnectionStringBuilder + { + DataSource = $"tcp:{server},1433", + InitialCatalog = database, + UserID = username, + Password = password, + MultipleActiveResultSets = false, + Encrypt = true, + ConnectTimeout = 30, + TrustServerCertificate = true, + PersistSecurityInfo = false + }; + return builder.ConnectionString; } public static string GetDatabasePasswordFronEnvFile()