Connectionstring in another Project (DLL)

by 1. January 2008 17: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.

image

 

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;
connection.Open();

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen