Are two SQL Server Connection Strings equal?


using System.Data.SqlClient;



public static bool AreEqual(string connectionString1, string connectionString2)
        {
            SqlConnectionStringBuilder connection1 = new SqlConnectionStringBuilder(connectionString1);
            SqlConnectionStringBuilder connection2 = new SqlConnectionStringBuilder(connectionString2);
 
            if ((connection1.InitialCatalog.ToLower() == connection2.InitialCatalog.ToLower() ||
                 connection1.AttachDBFilename.ToLower() == connection2.AttachDBFilename.ToLower()) &&
                connection1.DataSource.ToLower() == connection2.DataSource.ToLower())
            {
                return true;
            }
            else
            {
                return false;
            }
        }

Comments

Popular posts from this blog

Tutorial: Using Google Cloud Storage from C# and .NET

Late 2008 Macbook only giving 1.5 gb/s speed with 6 gb/s Intel SSD?

The ridiculous interview experience