Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading values from app.config
Message
From
02/04/2013 10:16:17
 
 
To
01/04/2013 11:49:08
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
Miscellaneous
Thread ID:
01569562
Message ID:
01569733
Views:
28
>>>:-}
>>>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

Thanks Bonnie,

when I try that I get a message that I cannot implicitly convert the value to a string so I need to add ".ToString()".

Is that expected?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform