WPF - Storing Connection String in App.xaml and Retrieving in Code



To Store Connection String in App.XAML file

 public partial class App : Application
    {
        public App()
        {

            string connectionStr = "Password=umsweb;Persist Security Info=False;User ID=umsweb;Initial Catalog=PROUSER;Data Source=10.5.3.226;Integrated Security=True";

            Application.Current.Properties["connectionStr"] = connectionStr;

        }

    }

To Retrieve Connection String from App.XAML file

  string strConnString = Application.Current.Properties["connectionStr"].ToString();

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.