473,320 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Settings Question

Hi,

I am working on a web project and have split my data access layer into a
separate DLL. This separate DLL uses a .settings file to store the
connection string. A strongly-typed settings class is generated for me in
the background. However, this generated class is internal.

My problem is that I need to get to the connection string from the web
project in order to configure my logging subsystem (which logs to the DB).
Now, I can think of an obvious hack around this. I could just put something
like this in my DAL DLL:

public static class ConnectionDetails
{
public static string ConnectionString
{
get
{
//the Settings class is internal
return Settings.Default.MyConnectionString;
}
}
}

What I'm wondering is whether there is a better solution to this. Have I
overlooked something obvious here?

Thanks,
Kent
Jan 31 '06 #1
3 1376
Kent,

In 2.0 is the connectionstring when using the designer placed in the
app.config with a windowsform application.

Windowsform version
<connectionStrings>
<add
name="WindowsApplication1.My.MySettings.NorthwindC onnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Data
Source=C:\test1\Northwind.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>

Which than can be used in VBNet as
Me._connection.ConnectionString =
Global.WindowsApplication1.My.MySettings.Default.N orthwindConnectionString

And in C#

this._connection.ConnectionString =
global::WindowsApplication1.Properties.Settings.De fault.NorthwindConnectionString;

I hope this helps,

Cor


Jan 31 '06 #2
Hi Cor, thanks for the reply. Unfortunately, that does not help me because
my .settings file is in a DLL, not an application. Therefore, I need a way
to open the configuration for the DLL from my web project. The
ConfigurationManager class does not have such a method. Do you know if this
is possible?

Thanks,
Kent

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Kent,

In 2.0 is the connectionstring when using the designer placed in the
app.config with a windowsform application.

Windowsform version
<connectionStrings>
<add
name="WindowsApplication1.My.MySettings.NorthwindC onnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Data
Source=C:\test1\Northwind.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>

Which than can be used in VBNet as
Me._connection.ConnectionString =
Global.WindowsApplication1.My.MySettings.Default.N orthwindConnectionString

And in C#

this._connection.ConnectionString =
global::WindowsApplication1.Properties.Settings.De fault.NorthwindConnectionString;

I hope this helps,

Cor


Jan 31 '06 #3
Kent,

I have tried this, I have made in the same way a class library and used that
in my webapplication.

No problem at all.

Cor
Jan 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Gouge | last post by:
Hi all, A question on the verge of being OT, but here goes: In my c# project in VS2005, I have a Properties folder in the Solution Explorer and within that a Settings.settings file. At first...
4
by: Ron Gliane | last post by:
From the documentation I could find, it seems that reading “appSettings” from the app.config file is now done through ConfigurationManager.AppSettings for ..NET 2.0, instead of the obsolete...
1
by: Zoe Hart | last post by:
Prior to VS2005 I configured my applications via the appSettings section of the app.config file. When I developed a class library, I used ConfigurationManager.AppSettings(settingName) syntax and...
3
by: Arthur Dent | last post by:
Hello All,.. I have some settings stored in the project settings which show up under My.Settings. ... All works fine. Now, I wanted to change the value of one of these settings, so I went...
5
by: Andy | last post by:
I need to write a VB.NET WinForms app. For this purpose I need to keep some settings of the application, like many other Windows applications do. The most obvious solution is to store settings in...
2
by: Regnab | last post by:
I'm creating a database that will be used independently at different sites (in the same company). Given the fact that there will be inevitable changes down the track, I'm trying to work out the...
4
by: RedHair | last post by:
I developed a Win form with VS.NET 2005 + .NET 2.0 in C# There are some application settings are "User" scope and stored in xxx.settings, I can access them via Settings class and changethem with...
5
by: t f | last post by:
Hi Okay this should be a simple one... In my solution i have 2 projects (one class library and one control library) - they both share the name default namespace - question is I want to be...
1
by: Tony | last post by:
Hello! I use VS2005 and within folder properties there is a file called Settings.setting. I can remove this file and rebuild the application without any kind of error or problems. So my...
3
by: Bob Altman | last post by:
Hi all, In my VB 2005 project I create a setting called UpgradeRequired with a default value of True, and I include the following code that runs when the project is launched: If...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.