Gokul's Blog

Get value from Registry settings in C#

Leave a comment

The below method is used to get the connection string from Registry or BizTalk Config file

public static string GetConnectionString()
        {
//            RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"Software\MYcompany\Connstring");
//            String sConn = (String)reg.GetValue("ConnStr", "Integrated Security=SSPI;Data Source=.;Initial Catalog=BizTalkMsgBoxDb");
//            reg.Close();
            string sConn;
            // Read from the BTSNTSvc.exe.config
            sConn = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString();
            if (sConn.Length <= 0)
            {
                  throw;
            }
            return sConn;
        }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s