Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading values from app.config
Message
From
01/04/2013 11:49:08
 
 
To
01/04/2013 10:51:19
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
Miscellaneous
Thread ID:
01569562
Message ID:
01569663
Views:
38
Likes (1)
>>:-}
>>But since that looks like connection string info I was wondering why you were not using the connectionString section ?
>
>I just used the example I found on-line. Does the app.config have pre-set sections? I didn't know that, I thought I could use anything I wanted.


Hi Frank,

You can put connection strings in the appSettings section and it works fine. But, there is also a connectionStrings section (as Viv says), and you can also use that for connection strings. We do it both ways, actually.

This is what it looks like:

The section in the app.config:
  <connectionStrings>
    <add name="QueueLocal" connectionString="server=(local);uid=sa;pwd=MyPassword;database=queue"/>
    <add name="QueueAzure" connectionString="Server=tcp:MyAzure;User ID=MyId;pwd=MyPassword;Database=queue;Trusted_Connection=False;Encrypt=True"/>
  </connectionStrings>
To access the connection string in C#:
string connString = ConfigurationManager.ConnectionStrings["QueueLocal"];
~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform