Tech Talk A software developer on all things tech, and then some


Getting the Connection String From Your App.Config In WPF and C#

I am using Active Reports and came across a problem where I needed to send the report a connection string. Before I would build the connection string based on what database was used, etc... from an INI file. Now we moved to a MvvM structure with the connection string in the App.Config. I had found a common solution :


This worked for earlier versions, but I am currently using .Net 4.0. Since I was using WPF, I added the reference to System.Windows.Forms then referenced it. Then I used the following code :

//sqlDBDataSource is a Connection string property for the Active Reports
//Demo is the name of my project in DemoDatabaseSetting
sqlDBDataSource.ConnectionString = ConfigurationManager.DemoDatabaseSetting.ToString();
Comments (2) Trackbacks (0)
  1. Very informative post. It is very simple and understandable due to which it’s more helpful for beginner as me as well as developer. I have found a nice post too over the internet which also explained very well. For more information of that post check out this link…

    Thanks everyone for your precious post!

Leave a Reply

No trackbacks yet.

%d bloggers like this: