Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Store Connection String
Message
De
01/11/2008 19:56:18
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01358780
Message ID:
01358918
Vues:
17
>When I compile, I get the error:
>"Non-invocable member 'System.Configuration.ConfigurationSettings.AppSettings' cannot be used like a method:


Typo on Paul's part ... use brackets [] instead of parentheses ()

~~Bonnie




>
>
>>>How can I store a DB connection string with my C# project? I have different string determined by where I'm working at, so I'd like make it work around that.
>>
>>If it's a desktop app save in the app.config file, for a web app saving it in the web.config file. Something like:
>>
>>Desktop:
>>
>>
>><configuration>
>>  <appSettings>
>>   <add key="connection" value="connection string here"></add>
>>  <appSettings>
>></configuration>
>>
>>
>>Read it with:
>>
>>
>>   using System.Configuration;
>>   //
>>   string connString = ConfigurationSettings.AppSettings("connection");
>>
>>
>>Web:
>>
>><connectionStrings>
>>  <add name="connection" connectionString="conn string here"/>
>></connectionStrings>
>>
>>
>>Read it with:
>>
>>System.Configuration.ConnectionStringSettings connSetting = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connection"];
>>string connString = connSetting.ConnectionString;
>>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform