Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to retrive Application Settings in a referenced project?

Status
Not open for further replies.

j0em0mma

Programmer
Jul 31, 2003
131
US
I have a main project (presentation layer) containing all of my forms and a data access layer which I am designing to return adapters to my BRL. If I define application settings in the main project, how do I retrieve them in the Data access layer which is referenced by the main presentation layer?

I have tried this:

Code:
        Return "Data source=" & ConfigurationSettings.AppSettings("TRSDBServer") & "," _
                              & ConfigurationSettings.AppSettings("TRSDBPort") & ";Integrated security=SSPI;Initial Catalog=" _
                              & ConfigurationSettings.AppSettings("TRSDBName")
but it complains and produces nothing

I have tried this:
Code:
 Dim aConfig As Configuration.ConfigurationSettings
    Dim strDBConnectTest As String = aConfig.AppSettings("TRSDBName")
but it complains and produces nothing

This:

Code:
        Return My.Settings.Item("TRSDBServer")
complained the least but failed at Runtime, claiming there was no such variable.

This works in my main presentation layer (where the application settings are stored):
Code:
objConnection = New SqlConnection("Data source=" & My.Settings.TRSDBServer & "," & My.Settings.TRSDBPort & ";Integrated security=SSPI;Initial Catalog=" & My.Settings.TRSDBName)

I could use my StateControl Class with a public shared string property and just store this from the presentation layer at application startup and use it wherever, but this seems woefully incorrect. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top