0

Hi everyone,
I'm n00wbie to C# and I I have one question.
I'm writting class for access to MySQL over DbLinq and I need to know connection string. I know that I can read connection string from webconfig file. My question is is there any function in C# that I can use during runtime to get answer for connection string independent of that I'm executing web application or desktop application (read from appconfig) ????

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by apegram
0

I'm not sure I get the nature of the question.

You can certainly use the exact same code to retrieve the connection string in either a desktop or web scenario. ConfigurationManager.ConnectionStrings["name_here"].ConnectionString will retrieve the information you need, whether it be in web or app.config. You will probably need to update your reference to System.Configuration in the project, however.

0

I imported using System.Configuration;
but there is one error in desktop
Error 1 The name 'ConfigurationManager' does not exist in the current context C:\Users\dominum\Documents\Visual Studio 2008\Projects\WindowsFormsApplication6\WindowsFormsApplication6\Form1.cs 22 39 WindowsFormsApplication6

0

That's why I said you need to set a reference.

From Solution Explorer, right click on References and select Add Reference. Scroll down and select System.Configuration.

From the menu bar, you can go to Project -> Add Reference.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.