Connectionstring in another Project (DLL)

by Damiaan Peeters 1. January 2008 16:49

I always put my datalogic into a different project.  Like this i can reuse my DL in other projects with the same purpose or customer.  [more]

To change or get a connectionstring is normally impossible because the Settings class is declared as internal.  This means that the complete project is able to access this property, but other projects (dll's) are not allowed to access this property.

If you try to access this, you will see get an error like this:

'DamPee.MyProject.DL.Properties.Settings' is inaccessible due to its protection level   

If you open the Settings, you will see the Access Modifier.  Change this to Public.



Now you will be able to access the Settings (including the connectionstrings) in your other projects.

connection.ConnectionString = global::DamPee.MyProject.DL.Properties.Settings.Default.MyProjectConnectionString;

Certified Umbraco Master, Part of Umbraco Certified partner comm-it, .Net and Azure developer, seo lover. Magician in my spare time.

Month List