If you run into the issue that System.Configuration.ConfigurationManager Does Not Exist you may find this article handy. You just need to add a reference to System.Configuration. If you need more information on how to use it, read on.
In you app.config create your connection string. Example:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configsections>
</configsections>
<connectionstrings>
<add name="SomeConnectionString" connectionstring="Data Source=localhost;Initial Catalog=Adventureworks;Integrated Security=True" providername="System.Data.SqlClient">
</connectionstrings>
</configuration>
Then in your code add a using System.Configuration. Then, add a reference to System.Configuration. If you don't - you wont get the ConfigurationManager in IntelliSense.
string connString =
ConfigurationManager.ConnectionStrings["SomeConnectionString"].ToString();
You might think just including the statement "using System.Configuration;" would work - but it will not expose the ConfigurationManager untill you add it as a referenced item.
Share This To :
0 comments:
Post a Comment