Get BizTalk SQL Server name from registry

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

<pre>
        /// <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 "";
            }
        }
</pre>

Uncategorized  

Leave a Reply