Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading values from app.config
Message
De
02/04/2013 10:16:17
 
 
À
01/04/2013 11:49:08
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
Divers
Thread ID:
01569562
Message ID:
01569733
Vues:
27
>>>:-}
>>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform