A way to get the BizTalk SQL Server name from the register, and use it to build a connection string:

        /// <summary>
        ///  Code sample of how to get connection string from the  Registry. 
        /// </summary>
        /// <param name="DBName"></param>
        /// <returns></returns>
        public static string DynamicSQLConnectionStringOLEDB(string DBName)
        {
            try
            {

                Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWAREMicrosoftBizTalk Server3.0Administration", false);

                string ConnString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=" + DBName + ";Data Source=" + rk.GetValue("MgmtDBServer").ToString();

                return ConnString;

            }
            catch
            {
                return "";
            }
        }

Tagged with:

Filed under: SQL